'Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10

Microsoft just introduced a Linux subsystem in its Windows 10 Anniversary Edition. The installation is pretty straight forward, but I could not locate bash files on Windows.

How does it work? What does ~ refer to in Windows? Where to find .bashrc?



Solution 1:[1]

Sorry for the misunderstanding, I check on google and it will be at C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME .

I tried and it works, in the cmd just type cd\ && dir *bashrc* /s it will locate the file, and in my case i see the line C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME but when I want to navigate it with the window browser it doesn't work, but if you copy paste it, it works :-)

I found it here.


Considering that you need to know where a file is located you can use the find command.
The syntax of the command is find {search-path} {file-names-to-search} {action-to-take}by default the action to take is printing the file name.
So if you are finding .bashrc file you can use find / -name .bashrc the bash will return you /home/yourusername/.bashrc

Also, if you want to access to your home directory you can use cd ~
Hope my answer will be helpful :-)

Solution 2:[2]

~ means that is user home folder, way like /home/%username%/

you can list files like ls -al and see .bashrc file.

Solution 3:[3]

just type vi ~/.bashrc

and that should put you into the file where ever it is. You can navigate there simply by doing cd ~ List all files with ls -a and you should be able to see it.

Solution 4:[4]

Right now on WSL 2 you can find it under /home/{user_name} and the file is hidden.

You can access it from Ubuntu console by {text_editor} .bashrc

If you want to edit that in Windows just type in ubuntu console explorer.exe . and it opens the current folder and shows all hidden files. It's weird but works fine.

Solution 5:[5]

Other answers doesn't work for me using WSL 2.

The LocalState folder contains a virtual disk so rootfs does not exist,

and AppData\Local folder does not have the Lxss folder.

The solution for me is surprisingly simple:

wsl -u root

This will allow you to get into wsl as root.

From here, you have access to the whole linux. Fix the .bashrc or anything you want.

Don't screw up the root user. :)

Solution 6:[6]

I find my .bashrc file in:

/home/your_user_name

you can run cd /home/your_user_name or cd ~ should work as well

If you previously installed git bash for window, you may also find .bashrc file in your window user profile folder. In Linux subsystem, you may local the file under /mnt/c/Users/your_window_user_name/.bashrc However, modifying that file only works for git bash in window but not for the shell terminal of the Linux subsystem.

Note: my installation of the Ubuntu is 20.04 LTS straight from window store.

Solution 7:[7]

The Python Selenium framework, SeleniumBase, comes with a special pytest command-line option called, --reuse-session, which tells all your tests to reuse the same browser session, even if all the tests live in different Python files. (More info on SeleniumBase command-line options here.) When using --reuse-session mode, the first test run will spin up the web browser, and then the last test run will close it. This should give you what you're looking for, where a different Python script closes the browser than the one that originally opened it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shayan Shafiq
Solution 2 James M
Solution 3
Solution 4 Adam Tomaszewski
Solution 5 unional
Solution 6 Anthony Lei
Solution 7 Michael Mintz