environment_variables

Differences between revisions 17 and 18
Revision 17 as of 2007-01-04 18:15:14
Size: 2522
Editor: 87-127-101-243
Comment: Documented ugly problem with $LANG being defined in 2 places
Revision 18 as of 2007-01-11 10:28:30
Size: 2551
Editor: 89
Comment: Added doc category
Deletions are marked like this. Additions are marked like this.
Line 60: Line 60:
----
CategoryDocumentation

TableOfContents

Global Environment Variables

These may be put in one of these files:

  • /etc/environment (try this file first)
  • /etc/profile

For example, to set a variable called JAVA_HOME and append it to PATH:

for /etc/environment:

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

(A colon followed by no directory is treated as the current working directory)
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games:$JAVA_HOME:"

for /etc/profile:

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

export PATH="$PATH:$JAVA_HOME:"

Locale Environment variables

Some programs rely on the value of $LANG, which defaults to en_US.UTF-8. (For example, Thunderbird changes the displayed date format based on this). The variable is set in both /etc/enviroment and in /etc/default/locale. To make a system-wide change that is certain to take effect, both of these must be modified; it's also necessary to log out and back in again.

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.

If instead you want a temporary variable created only for your current shell session, then do this inside the shell:

export SOMEDIRECTORY="/some/location"
export SOMEVALUE="500"

Bash Shell Environment Variables

Some of what is mentioned below may be specific to Ubuntu only.

  • when starting a shell after you've logged in already, either from the console or thru X display manager, that shell will be an interactive non-login shell, which will read /etc/bash.bashrc and ~/.bashrc.
  • when the user starts a bash shell by logging into a console or via SSH, this starts a login shell, which will read /etc/environment, /etc/profile, /etc/bash.bashrc, ~/.bash_profile, ~/.bash_login, and ~/.profile.
  • 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.

Display contents of $PATH

Just `echo $PATH'

References

See Also

[:OneTruePath: OneTruePath]


CategoryDocumentation

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