When are Environment Variables Set In Linux?
When you first login to your user account (via GUI login screen, via SSH, etc), ~/.profile
script is run. This script takes environment variables specified in /etc/environment
and puts them in the $PATH
environment variable.
When you launch a terminal, ~/.bashrc
is run. This will run /etc/bash.bashrc
(“global bashrc that is run for every user”).
This chain of scripts running set up your environment variables, as well as other things (like terminal colors/behavior, etc).
- When you login,
~/.profile
is run, which will add environment variables specified in/etc/environment
.- Each time you open a terminal,
~/.bashrc
is run, which runs/etc/bash.bashrc
, both of these can modify$PATH
(as well as other environment variables)