Environment variables allow users to define/modify operating system level variable. Any changes made to the environment variables will impact the operating system functionality.

"export" shell command is used to setup a new environment variable or modify an existing environment varaible.

Syntax:

export NAME=VALUE

Example

export PATH=/home/santhosh:/home/java/bin

Please note that the path separator is colon while setting the PATH variable. Let's say, you've already set one variable and you would like to append extra value to it. You could do as below

export PATH=$PATH:/santhosh/open-office

echo shell command

"echo" shell commnad prints the data onto the screen. And this will print the environment variable that has been set if we give name followed by dollor($).

Syntax:

echo $NAME

Output

Santhosh>echo $PATH
/home/santhosh:/home/java/bin

env shell command

"env" shell command prints/lists all the environment variables that are currently being set to current linux kernel.

Syntax:

env

Output

INFODIR=/usr/local/info:/usr/share/info:/usr/info
HOSTNAME=santhosh
GNOME2_PATH=/usr/local:/opt/gnome:/usr
TERM=xterm
SHELL=/bin/bash
PROFILEREAD=true
HISTSIZE=1000
SSH_CLIENT=192.168.1.1 62345 22
GNOME_PATH=:/opt/gnome:/usr
USER=santhosh
XNLSPATH=/usr/X11R6/lib/X11/nls
HOSTTYPE=x86_64
XDG_CONFIG_DIRS=/usr/local/etc/xdg/:/etc/xdg/:/etc/opt/gnome/xdg/
GNOMEDIR=/opt/gnome
CPU=x86_64
PWD=/home/santhosh
LANG=en_US.UTF-8
HOME=/home/santhosh
OSTYPE=linux
LS_OPTIONS=-N --color=tty -T 0
XCURSOR_THEME=Industrial
MACHTYPE=x86_64-suse-linux
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:/opt/gnome/share/info
LESSCLOSE=lessclose.sh %s %s
G_BROKEN_FILENAMES=1
COLORTERM=1