I don't know how to phrase this to be clear. I'm not talking about terminals or shells, I know what the difference between login and non-login shells are. What I want to know is when I start up my computer and log in to the desktop, do any of the "dot files" (.profile, .bash_profile, .bashrc, etc.) in my home folder get run? If so, which ones?

I'm asking because by default most terminal apps you open don't use login shells by default, but I've read advice saying not to modify things like environment variables in your .bashrc file, to instead put it in .bash_profile, but how am I to set those things if I'm primarily using non-login shells? Or is that advice maybe aimed at people who SSH into their workstations?

I obviously know how to work around any of those issues, I'm more explaining why I am curious about it than describing a problem I've run into.

  • see /etc/profile to begin with. That file will show a lot of what is happening and is a starting point to see all other files.
    – Rinzwind
    Feb 2, 2016 at 19:12
  • 1
    When you log in to a graphical session with lightdm, /etc/profile and ~/.profile are sourced, and variables which are set there and exported will be available throughout the session. That's not the case with ~/.bashrc and ~/.bash_profile. Feb 2, 2016 at 20:09

1 Answer 1


Actually this is a great question for Unix & Linux because it is not only related to Ubuntu.

There is a really nice answer on SuperUser which describes the Difference between .bashrc, .bash_profile and .profile. The accepted answer explains this pretty well. Here are some relevant parts from that answer:

Bash is a Bourne-like shell. It reads commands from ~/.bash_profile when it is invoked as the login shell, and if that file doesn't exist¹, it tries reading ~/.profile instead.
If the shell is not a login shell, it doesn't read ~/.profile. When you start bash as an interactive shell (i.e., not to run a script), it reads ~/.bashrc

There is also some information about logging in using X:

On modern Unices, there's an added complication related to ~/.profile. If you login in a graphical environment (that is, if the program where you type your password is running in graphics mode), you don't automatically get a login shell that reads ~/.profile. Depending on the graphical login program, on the window manager or desktop environment you run afterwards, and on how your distribution configured these programs, your ~/.profile may or may not be read.

So if I understood your question correctly, you are asking what file is loaded if you log in in graphical mode (using lightdm, in this case your login screen is probably the Unity Greeter). And here I'm pretty sure that in this case it is .profile. The accepted answer from this question also tells us that:

Most combinations of display manager (the program where you type your user name and password) and desktop environment read ~/.profile from the login scripts

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .