Environment variables

Setup of environment variables for bash, zsh, fish, as well as Windows.

Also see Arch Wiki | env. variables.

For all users

  • /etc/profile is sourced by all POSIX-compatible shells upon login.


  • ~/.profile or ~/.bash_profile for login bash shells.
  • ~/.bashrc for every bash instance.


  • ~/.zshenv for environment variables in zsh.
  • ~/.zprofile for login zsh shells.
  • ~/.zshrc for every zsh instance.

⚠️ zsh does not read ~/.profile by default due to syntax difference. You can do this instead in ~/.zprofile

[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'

PAM module

  • ~/.pam_environment : only supports KEY=VALUE, KEY DEFAULT=VALUE, ${HOME}, ${SHELL}.

⚠️ Sourcing from ~/.pam_environment is being deprecated.


  • ~/.config/environment.d/*.conf : files are read by systemd in the WayLand session.

Graphical environment

  • ~/.xinitrc is sourced by startx.
  • ~/.xprofile is sourced by display managers (e.g. GDM, SDDM)


Shell variables

Using set. They will vanish once the shell is closed.

set x=123
echo %x%  # You need to wrap the var between % to show the value

Persistent variables

  • Set Environment Variables in the Advanced system settings GUI in the control panel.
  • setx. See setx /? for the complete options