Take the 2-minute tour ×

In order to export variables permanently, we can write the export command in the following files:


In my case, ~/.bash_profile does not exist, and therefore I export the variable in the other two files:

export country=UK

The problem I have now is that the variable I defined (country) is still unknown for the system. I was wondering what I should do next. Thanks!

share|improve this question
If you define variables in ~/.profile or ~/.bashrc (or whatever shell you are using. It is not always bash) then you set those only for yourself. They only get executed when you log in. (and only after you log in, if you changed those and did not logout and back in then they will not yet have taken effect). The same holds for /etc/profile, though that will affect all users. -- However what I am missing is your goal. Did you just choose a random example (country), or do you want to set a locale? –  Hennes Dec 17 '12 at 12:30
possible duplicate of How do I set environment variables? –  hhlp Dec 17 '12 at 14:07
add comment

2 Answers

up vote 1 down vote accepted

profile is only read when you login, have you tried a login shell bash -login,bash -,logging out and then back in or just plain old rebooting?

You can use .bashrc if want it every time you spawn a shell.

share|improve this answer
@Hennes Your comment is overkill bash -login is already mentioned. –  Shutupsquare Dec 17 '12 at 12:40
add comment

If you want these variables to be available for all the users on the system, you can define them in /etc/environment.

share|improve this answer
add comment

Your Answer


