Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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. – squarebear Dec 17 '12 at 12:40

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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