1

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.

  • 3
    Try ~/.profile – steeldriver Oct 23 '16 at 22:19
  • It's not ~/.profile. That isn't executed at all in an interactive non-login shell. – Carl Zulauf Oct 23 '16 at 22:35
  • 1
    @CarlZulauf: In a desktop session it's sourced by the display manager (lightdm). So it's most certainly the file in question. – Gunnar Hjalmarsson Oct 23 '16 at 22:40
  • @GunnarHjalmarsson you are correct. I didn't realize the desktop session itself loads ~/.profile (which explains why gnome-terminal defaults to non-login shells) and requires logging out to take effect. Sorry @steeldriver for not understanding why you were correct. – Carl Zulauf Oct 23 '16 at 22:50
3

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.

  • 1
    To be more precise: /etc/environment is read by PAM and not sourced by anything. /etc/profile and ~/.profile are sourced by lightdm, but the former is not involved in setting environment variables by default. – Gunnar Hjalmarsson Oct 23 '16 at 22:56
  • 1
    Congrats on answering your own question. Don't forget to accept it as the solution in two days so others know it's the accepted answer. – WinEunuuchs2Unix Oct 23 '16 at 22:59
2

you can find this out by run bash in in debug and login modes , its quite enlightening

/bin/bash -xl

There is quite lot of output but you should be able to see the whole chain of loading files and modifying $PATH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.