DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Config Environment Variables on Linux


System-wide environment variables

Add global environment variables in file /etc/environment. This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line:

JAVA_HOME=/usr/lib/jvm/default-java

So do not add "export" before assignments. Variable expansion does not work in this file.

User specific environment variables

Add user level environment variables in file ~/.zshenv. For example, to override system PATH:

export PATH=$HOME/apps/spark-1.0.2-bin-hadoop2/bin:$PATH

User aliases setup

For bash there is a ~/.bash_aliases file, so we define aliases in this file, and load it in zsh with adding following codes into ~/.zshrc:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

Some example in ~/.bash_aliases:

alias gst='git status'
alias dn='$HOME/apps/dsnote/donshell.sh'

Refs:

  • EnvironmentVariables on UBUNTU wiki.

  • Zsh on ArchLinux Wiki.

  • What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?.

  • What is the correct target for the JAVA_HOME envrionment variable for a Linux OpenJDK debian-based distribution?.



Published

Oct 6, 2014

Last Updated

Oct 6, 2014

Category

Tech

Tags

  • env 2
  • linux 158
  • mint 24
  • zsh 5

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor