How to set up environment variable properly?
Solution 1
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.
Solution 2
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
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I opened the
/etc/environment
and added the lineANDROID_SDK_HOME="/home/tom/android-sdk"
but I triedecho $ANDROID_SDK_HOME
but displayed nothing. I haveJAVA_HOME
in the same/etc/environment
but its working. Please help me fix the problem. Thanks in advance.