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.

I opened the /etc/environment and added the line ANDROID_SDK_HOME="/home/tom/android-sdk" but I tried echo $ANDROID_SDK_HOME but displayed nothing. I have JAVA_HOME in the same /etc/environment but its working. Please help me fix the problem. Thanks in advance.

share|improve this question
    
I'm guessing the file never gets opened yet. Run source /etc/environment from a command line and echo the variable again. –  Anko Mar 12 '13 at 0:52
1  
It worked. Please put your comment as answer so I can accept it. –  TheOnlyIdiot Mar 12 '13 at 1:04
1  
I'm happy I helped. TheKoju's answer is a more permanent fix -- accept that one. –  Anko Mar 12 '13 at 1:10
    
Isn't the main difference that /etc/environment is system wide and /home/nobody/.profile is specific to the user nobody? Both should be persistent / permanent. Both approaches have their place –  xeraa Aug 8 '13 at 0:23

2 Answers 2

up vote 8 down vote accepted

Environment variables can be defined permanently by editing the .profile file in your home directory. Here's how:

Edit your .profile file with a command like gedit ~/.profile. Append this to the end of the file:

export ANDROID_SDK_HOME=/home/tom/android-sdk

You can source .profile to make it apply right away. Each time you restart your system, the .profile file is loaded, restoring this setting.

share|improve this answer

Its not recommended to use .profile file anymore to store user specific environment variables.

Use ~/.pam_environment file instead.

See: https://help.ubuntu.com/community/EnvironmentVariables

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.