Where and How to Set Environment Variables in Linux

26Feb09

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

Advertisements


No Responses Yet to “Where and How to Set Environment Variables in Linux”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: