Ubuntu – I can’t find .bash_profile

10.10bashcommand line

I am trying to learn how to tweak my shell in the file but can't seems to find the file in my home directory or in /etc/profile.

Is there any other file I need to search for, or am I expected to create one from scratch?

Best Answer

If you open Nautilus, the file browser, go to your HOME directory and press CTRL+H you will see then all the hidden files (since hidden files start with the DOT . character). Since you are talking about the .bash_profile, I am guessing you want to start via console instead of an interactive desktop.

The difference between .bash_profile and .bashrc is the following:

  • .bashrc is the one that you edit when you want to change the way xterm or gnome-terminal open the console. how the bash works in this interactive places.

  • .bash_profile is the one you edit when you want to change how bash works when you login via console (Like the same way you login to a Ubuntu server or when you press CTRL+ALT+F1 to start a terminal)

Since .bash_profile does not come by default, you can just create it. But as I understand the default .bash_profile is now called .profile which can be seen in the HOME directory. Both, .bashrc and .profile can be edited to change how bash works in both, interactive and console modes.

NOTE: If by some way you create .bash_profile, then Ubuntu wont read .profile but instead go directly to .bash_profile since both of them are the same but .bash_profile has more compatibility because of old ways. So basically you do not need .bash_profile if you have .profile. So just remember:

.bashrc - Interactive Console/Terminal (Gnome, KDE, Xfce...)

.profile - TTY Console/Terminal