I run ubuntu 12.04.1 LTS. And I can't get what is the order/priority for loading profile files. When I start the system and login using GUI which file is loaded? And why? What if run login-shell? Will it be the same? Actually right now I can't get why my ~/.profile doesn't load when system starts because here I see it should:


  • How are you testing whether ~/.profile is loaded? – Andrea Corbellini Dec 19 '12 at 20:24
  • There is environment variable is updated in ~/.profile – sunprophit Dec 19 '12 at 20:25

You may define a variable in every file:




and perform an

echo ${ORDER}

to see, what was involved and in which order. Of course it will not tell you, if there were different scripts you missed.

So if you see one source mentioned, read that script to look, whether one script sources another one, and include these too.

/etc/bash.bashrc and ~/.bashrc and ~/.bash_login come to mind, as well as things from /etc/default.

  • Hm, $ORDER is empty, which means none of them are loaded? – sunprophit Dec 20 '12 at 9:40
  • Not sure why $ORDER was empty, maybe because of some syntax error. I don't know a lot about dash and bash differences. Although I am going to mark you answer as the correct one because it helped to get where is the problem. – sunprophit Dec 20 '12 at 10:49

It all depends on with which user you're trying to log in. The global /etc/profile file is loaded for every user, while the ~/.profile is only loaded for the user.

~ points to the current user's home directory. So, if you would put it in /home/user-a/.profile and login as user-a, both global and its user-specific file are loaded (in that order), whereas if you would login as user-b without a .profile file, it only loads the global one.

  • In current user's profile (~/.profile) there is part which should update environment variables. I mean it's not in some another profile. It's profile of this user. But I tried @user_unknown solution to test profiles loading and it seems none of them are loaded. – sunprophit Dec 20 '12 at 9:49

Both should be loaded, and ~/.profile should be loaded last (meaning it has priority).

  • Then I am not sure what is going on. If I run it explicitly in terminal it loads. Could there be problem during login and in result ~/.profile doesn't load, but then in terminal there is no these problems. Could I check if system tried to load it? – sunprophit Dec 19 '12 at 20:20

It's my fault. There was [[ some_test ]] in my ~/.profile and it runs good in bash, but I guess dash runs some pre_session_creation/post_session_creation commands on session start and dash don't know [[ keyword. So everything had been loaded but stopped at the error.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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