environment_variables

Differences between revisions 1 and 2
Revision 1 as of 2006-11-16 23:54:20
Size: 1726
Editor: c-68-61-204-103
Comment:
Revision 2 as of 2006-11-16 23:55:54
Size: 1724
Editor: c-68-61-204-103
Comment:
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
So simply append whatever variables you need defined in your ~/.bashrc file. So just append whatever variables you need defined to your ~/.bashrc file.

TableOfContents

Global Environment Variables

These may be put in one of these files:

  • /etc/profile
  • /etc/environment

To append 'testbin' to the PATH environment variable and to set a variable called JAVA_HOME and append it to PATH:

export JAVA_HOME="/usr/lib/j2sdk1.5-sun"

(A colon followed by no directory is treated as the current working directory)
export PATH="$PATH:/home/user/testbin:$JAVA_HOME/bin:"

Session Specific Environment Variables

You may sometimes want variables defined locally (eg: restricted to your accounts shell only) and not globally (all users). So just append whatever variables you need defined to your ~/.bashrc file.

Bash Shell Environment Variables

  • when starting a shell after you've logged in already, either from the console or thru X display manager, that shell will be non-login, and only reads /etc/bash.bashrc and ~/.bashrc.
  • when the user starts a bash shell by logging into a console, this starts a login shell, which will read /etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order. Bash reads and executes commands from the first one that exists and is readable. The `--noprofile' option may be used when the shell is started to inhibit this behavior.
  • If Bash is invoked with the name sh, whether as an interactive login shell, or as a non-interactive shell with the --login' option, it first attempts to read and execute commands from /etc/profile' and `~/.profile', in that order.

References

environment_variables (last edited 2008-08-06 17:01:23 by localhost)