Category Archives: Uncategorized

How to set , unset and view Environment variables in Linux ?

What are the Environmental Variables?

An environment variable is a dynamic “object” on a computer that stores a value, which in turn can be referenced by one or more software programs.Environment variables are dynamic because they can change. The values they store can be changed to match the current computer system’s setup and design (environment). They can also differ between computer systems because each computer can have a different setup and design (environment).

There are number of environmental variables to set. As an example imagine if you want to config java runtime on your machine you have to set  JAVA_HOME variable.

How to set , unset Environmental variables in Linux?

In linux basically we use terminal commands to set and unset environmental variables. To set an environmental variable we use export   

export JPDA_ADDRESS=8000

export JPDA_TRANSPORT=dt_socket

If you want to remove once set environmental variable , you can use unset command.

unset JPDA_ADDRESS=8000

unset  JPDA_TRANSPORT=dt_socket

How to view set environmental variables?

If you want to see what are the set environmental variables you can use  printenv  command. It will print all the current environmental variables in your system.

Screenshot from 2015-05-04 14:16:16

To show a list including the variables created by yourself you can enter the following command

( set -o posix ; set ) | less

Screenshot from 2015-05-04 14:20:46

Advertisements