Skip to content

Instantly share code, notes, and snippets.

@fakemelvynkim
Created June 3, 2014 22:11
Show Gist options
  • Save fakemelvynkim/9e1718acf26f2dd3addc to your computer and use it in GitHub Desktop.
Save fakemelvynkim/9e1718acf26f2dd3addc to your computer and use it in GitHub Desktop.
loading persistent environment variables in Ubuntu

assignment expressions, one per line

~/.pam_environment
# FOO=bar
# PATH DEFAULT=${PATH}:${HOME}/MyPrograms

NOTE:

  1. You may not quote the value when doing a simple variable assignment like the FOO=bar example.

  2. The syntax used for modifying PATH, which syntax differs from script files, is required for variable expansion to work.

  3. ~/.pam_environment is written to when you use various GUIs to set the language or regional formats. Consequently, if you for instance set LC_TIME by editing ~/.pam_environment manually, your entry will be overwritten if you afterwards use the Language Support GUI to change the regional formats setting.

shell script

~/.profile
export FOO=bar
export PATH="$PATH:$HOME/MyPrograms"

assignment expressions, one per line.

/etc/environment
# JAVA_HOME="/path/to/java"

shell script, with .sh extension

/etc/profile.d/*.sh
# export JAVA_HOME="/path/to/java"

system locale (language) env

/etc/default/locale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment