Environmental Variables

The Linux shell is an application like the others. When launched, a shell application loads automatically a set of startup scripts:

  • A system initialization script
  • A user initialization script

Each variable declared inside these scripts will be available for each command and script launched inside the shell.

Let's take the common case of the “Bourne compatible shells” (sh, bash, ksh, ash). When launched, they loads these scripts:

  • /etc/profile
  • /home/username/.profile

For example, to add the “$HOME/bin” directory to the PATH variable:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

To execute in the shell your .profile script without logging out/in:

source .profile

linux/environmental_variables.txt · Last modified: 2010/08/10 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0