I can't find
.bash_profile in Ubuntu 14.04 in my
/home/user directory. I used the
ls -a command to see the
.bash_profile, but there isn't such a file.
you can create your
.bash_profile in Ubuntu but then
.profile will not be read.
If we read .profile content :
# ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists.
~/.profile instead of
That means the file does not exist. But, you can create the file and
bash executes/sources the file if
bash is invoked as a login shell. So evertime you login via a shell (for example via
If you want the content to execute everytime you open a terminal, then you should modify the
.bashrc file instead.
When invoking a login shell bash will looks for its config files in this order:
 ~/.bash_profile  ~/.bash_login  ~/.profile
After finding the first one, it stops looking for the others so if there is a
.bash_profile in my
$HOME bash will not look for
From these three file names, Ubuntu by default uses
.profile you can rename it to
.bash_profile if you like:
mv ~/.profile ~/.bash_profile
Now if we open a new bash shell using
su - $USER,
sudo -u $USER -i or any other commands that runs bash as a login shell,
~/.bash_profile will get sourced.
Important to note:
What I have talked about till now only applies to Bash itself, when you are logging into the system from a GUI, the display manager is responsible of sourcing the correct files.
gdm3 as its display manager, if we take a look at:
/etc/gdm3/Xsession we can see that none of the files will get sourced except:
# First read /etc/profile and .profile for file in /etc/profile "$HOME/.profile"; do if [ -f "$file" ]; then source_with_error_check "$file" fi done
so if you are using a GUI to login, keep the file under
.profile name otherwise you might miss some variables and settings in your environments.
I guess the better option is creating a symlink to
ln -s ~/.profile ~/.bash_profile
Now your data lives in
gdm doesn't miss anything, bash loads
.bash_profile which is actually
.profile, and by editing each of them you get the same result.
If you don't have
.profile then grab a copy of it from here:
cp /etc/skel/.profile ~/.profile
# Remember the note above cp /etc/skel/.profile ~/.bash_profile
If you mean the .bashrc you will find it in your home folder. If it isn't there, you can copy it from the /etc/skel folder to your home folder.
If you need some more information on this subject, please visit stefaan lippens page.
Top answer to use
~/.profile instead of
~/.bash_profile did not work for me.
Note: I'm using Ubuntu WSL.