Where and How to Set Environment Variables in Linux

By Ali Hammad Baig on 4:19 AM

Filed Under: , , ,

In Windows and Linux sometimes you need to set environment variables. Windows provide a graphical way to do so

In windows
Go to My Computer > Advance > Environment Variables and you can set the environment variables here

In Linux

You can set environment variables in different places. But in my opinion and whats works for me is that you set the environment variables in you_home_directory/.bashrc file.

Go to your home directory- mine is /home/baig- and show the hidden files (View/Show hidden files), find and open .bashrc file, go to the end of the file provide environment variables with 'export' key word.

For example, you will provide Java environment variables this way

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.16

and if you want to append a new entry to the existing environment variable for example, PATH env. variables then you can follow the following pattern

export PATH=$PATH:/usr/lib/jvm/java-1.5.0-sun-1.5.0.16/bin

0 comments for this post

Post a Comment

Blog Widget by LinkWithin