environment_variables
⇤ ← Revision 1 as of 2006-11-16 23:54:20
1726
Comment:
|
1724
|
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. |
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
[http://www.gnu.org/software/bash/manual/bashref.html Bash Reference]
[http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=5 Environment Variables @Gentoo Wiki]
environment_variables (last edited 2008-08-06 17:01:23 by localhost)