Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

~/.profile
~/.bash_profile
/etc/profile 

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
1  
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

2 Answers 2

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

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

 
discard

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.