4

This question already has an answer here:

When trying to access ~/.bash_profile from Ubuntu Xenial (16.04) in Windows Subsystem for Linux I get the following error:

-bash: /home/<username>/.bash_profile: No such file or directory

Where is it located and how do I edit it?

Thank you!

marked as duplicate by muru bash Oct 27 '17 at 14:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    I believe it is just .profile and .bashrc that are in the home folder in WSL. – Terrance Oct 26 '17 at 18:32
  • 1
    if it is not there and you want it ... you create it , add what you want to it and source it from somewhere (/etc/profile probably) – Rinzwind Oct 26 '17 at 18:43
  • I am not sure, but I do not think this is a duplicate as the question is about bash on windows and I am not sure if the question is about finding .bashrc from withing bash (duplicate) or windows (different path with unique problems, see the link in my answer). – Panther Oct 27 '17 at 19:03
8

From the man page for bash:

By default, it first reads and executes commands from the file > /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

So it exists in your home directory IF AND WHEN you create it and make it readable.

2

Bash subsystem

With the bash on windows the files are located at in the same location if you are running within the bash environment, ie /home/user_name/.bashrc .

Create the file , form bash, as suggested by Rinzwind if necessary.


Windows

However, if you are looking at the files from windows, outside the bash subsystem, they are located at

C:\Users\<username>\AppData\Local\Lxss\rootfs

so ...

C:\Users\<username>\AppData\Local\Lxss\rootfs\home\username

Note: The windows user name may or may not be the same as your bash username, depends on how you set bash up I suppose.

Warning - Dont edit or modify files in your bash environment from windows, see this link:

DO NOT, under ANY circumstances, create and/or modify Linux files using Windows apps, tools, scripts, consoles, etc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.