An environment variable is a named object that contains information used by one or more applications. Many users (and especially those new to Linux) find this a bit weird or unmanageable. This is however wrong: by using environment variables one can easily change a configuration setting for one or more applications.
The following table lists a number of variables used by a Linux system and describes their use. Example values are presented after the table.
| Variable | Description |
|---|---|
Below you will find an example definition of all these variables:
PATH="/bin:/usr/bin:/usr/local/bin:/opt/bin:/usr/games/bin"
ROOTPATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
LDPATH="/lib:/usr/lib:/usr/local/lib:/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3"
MANPATH="/usr/share/man:/usr/local/share/man"
INFODIR="/usr/share/info:/usr/local/share/info"
PAGER="/usr/bin/less"
EDITOR="/usr/bin/vim"
KDEDIRS="/usr"
CLASSPATH="/opt/blackdown-jre-1.4.1/lib/rt.jar:."
CONFIG_PROTECT="/usr/X11R6/lib/X11/xkb /opt/tomcat/conf \
/usr/kde/3.1/share/config /usr/share/texmf/tex/generic/config/ \
/usr/share/texmf/tex/platex/config/ /usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf
To centralise the definitions of these variables, Gentoo introduced the
For instance, when you installed
PATH="/usr/i686-pc-linux-gnu/gcc-bin/3.2" ROOTPATH="/usr/i686-pc-linux-gnu/gcc-bin/3.2" MANPATH="/usr/share/gcc-data/i686-pc-linux-gnu/3.2/man" INFOPATH="/usr/share/gcc-data/i686-pc-linux-gnu/3.2/info" CC="gcc" CXX="g++" LDPATH="/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3"
Other distributions tell you to change or add such environment variable
definitions in
For instance, when
This doesn't only benefit Portage, but also you, as user. Occasionally you might
be asked to set a certain environment variable system-wide. As an example we
take the
http_proxy="proxy.server.com:8080"
By using the same file for all your variables, you have a quick overview on the variables you have defined yourself.
Several files in
The
00basic 99kde-env 99local
+-------------+----------------+-------------+
PATH="/bin:/usr/bin:/usr/kde/3.2/bin:/usr/local/bin"
When you run
If you want to notice the effect of
# env-update && source /etc/profile
You do not always want to define an environment variable globally. For instance,
you might want to add
PATH="${PATH}:/home/my_user/bin"
When you relogin, your
Sometimes even stricter definitions are requested. You might want to be able to
use binaries from a temporary directory you created without using the path to
the binaries themselves or editing
In this case, you can just define the
# export PATH="${PATH}:/home/my_user/tmp/usr/bin"