Ubuntu – Where is PATH setup in Ubuntu 16.10 bash shell

16.10bashbashrccommand lineenvironment-variables

I can't seem to determine where the bash PATH environment variable is getting setup on my fresh Ubuntu 16.10 install.

I have tried placing echo $PATH statements at the top of ~/.bashrc and even /etc/bash.bashrc. Both echo statements get executed, so these files are loading properly, But, in both cases the PATH already contains the following:

/home/carl/bin:/home/carl/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

The first entries (/home/carl/bin:/home/carl/.local/bin) are what I'm trying to track down. I'm not really sure where any of the values are set since changing /etc/environment seems to have no effect.

The PATH is also setup when /etc/profile executes when using a login shell and is also unaffected by changes to /etc/environment.

Best Answer

Turns out the PATH was being persisted by the display manager loading ~/.profile, (and /etc/profile and /etc/environment) when creating a desktop session. This means changes to those files aren't going to reflect in new bash sessions and require logging out to take effect.

Related Question