Location of .Bashrc for "Bash on Ubuntu on Windows" in Windows 10

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

Since the Windows 10 Fall Creators Update, the location changed to:

C:\Users\USERNAME\AppData\Local\Packages\{DIST}\LocalState\rootfs\home\{LINUXUSER}\

Where:

  • {DIST} is equal to CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
  • {LINUXUSER} is the user for which you are looking for the .bashrc file

Just for anyone wondering that came here from Google.

What is the location of .bashrc on WSL?

So apparently WSL does not create a user by default.

One can be set up as follows

$ sudo adduser newuser # new user to play with, creates in /home/newuser like your default
$ sudo cp -aR /home/newuser /mnt/c/Users/<you>
$ sudo echo "echo 'running bashrc'" >> /mnt/c/Users/<you>/newuser/.bashrc
$ sudo usermod -d /mnt/c/Users/<you>/newuser newuser

Once you do that, you can edit the .bashrc profile within that user's home directory

That's at /mnt/c/Users/<you>/newuser/.bashrc as seen by ubuntu, or C:\Users\<you>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\newuser\.bashrc as seen by Windows

Alternatively, instead of creating a ubuntu user, you could place a .bash_profile in C:\Users\<you>

See this thread for more info: https://github.com/Microsoft/WSL/issues/2612

Git for Windows: .bashrc or equivalent configuration files for Git Bash shell

Create a .bashrc file under ~/.bashrc and away you go. Similarly for ~/.gitconfig.

~ is usually your C:\Users\<your user name> folder. Typing echo ~ in the Git Bash terminal will tell you what that folder is.

If you can't create the file (e.g. running Windows), run the below command:

copy > ~/.bashrc

The window will output an error message (command not found), but the file will be created and ready for you to edit.

WSL bash in Visual Studio Code running .bashrc but not .bash_profile

I can't reproduce this after even after upgrading to 1.70.1, so I'd recommend trying out these things:

  • try

     "path": "C:\\WINDOWS\\System32\\wsl.exe",
    "args": ["-e", "bash", "-li"]

    to make sure that a login shell is started

  • if this changed after upgrading, read Help -> Release Notes to find out what might be responsible, e.g. the Shell integration is now enabled by default, so you might try "terminal.integrated.shellIntegration.enabled": false

  • sync / backup your settings, re-install vanilla VSC, check if behaviour is still the same

Keep the Path between Windows and 'Bash on Ubuntu on Windows' in sync

As of Insider build 145963 (ish), you don't need to append the Windows path in your .bashrc:

In subsequent builds, and from Creators Update onwards, WSL automatically appends the Windows path to your Bash path, allowing you to launch Windows executables from within Bash without needing to enter the absolute folder location to executables that are on the path.

For example, navigate to a temp folder on your C: drive, create a text file and open it in notepad:

$ cd /mnt/c/temp
$ echo Hello > hello.txt
$ Notepad.exe ./hello.txt

Tip: Don't forget the .exe extension - that's what tells Linux to ask WSL to launch the .exe

Permission denied when starting .bashrc on ubuntu on windows

The error simply says that permission denied. Since the question is not completely clear, the following things can be tried:

1) Check the permission of the file ".bashrc" and ".profile" and make sure it is 0644

2) Check the upper level directory permission (here the folder /home/gian1312) and make sure it is 0755.

3) If the first two are fine, then you need to check the permission of the "path" which you are trying to add and it should have enough permissions to be readable by the user "gian1312"

Editing the answer as per the below comment:
To change the permissions, please run the below commands:

chmod 0755 /home/gian1312
chmod 0644 /home/gian1312/.bashrc
chmod 0644 /home/gian1312/.profile

./bashrc permission denied on windows10

Windows 10 does not know about file permissions in Ubuntu subsystem.
If you want to edit .bashrc just use native Ubuntu nano or vim code editors.

To open .bashrc use:

sudo nano .bashrc

To set file permissions:

chmod 644 .bashrc

This permissions is equal to

rw-r--r--

Can I get (the new) bash on Windows 10 to load .profile

By default, this release of Ubuntu-on-windows loads the file named .bashrc.

You can either put the script or add the below line to .bashrc (and create .bashrc if it is non-existent):

. ~/.profile

Note: If .bashrc is sourced from .profile, you may want to comment it out to prevent bash endlessly looping.



Related Topics



Leave a reply



Submit