/etc/environment not being read into PATH variable

6,694

Solution 1

If your shell is bash, it pays no attention to /etc/environment at least as far as the manpage and an strace bash says. Indeed, I can find no program listed that does mention /etc/environment.

I've run into similar situations under Ubuntu where there are 4 or more levels of indirection pointing to the datum that you really want. Often times I find it easier to fix the proximate, rather than the ultimate source of the datum.

In this case, modifying your personal path in ~/.profile is in fact the proper way to do it since at least V7 Unix.

Solution 2

No one really answered the root cause of this issue. @msw does have the correct solution however I want to explain what is going on.

In ubuntu when you use an application that is pam aware it will run through the list of modules listed in /etc/pam.d/* one of these modules used during login controls what environment variables get set. /etc/pam.d/login or /etc/pam.d/su are likely the modules that you triggered when logging into your user. In these files /etc/login.defs is used to determine your base environment as shown here.

#
# *REQUIRED*  The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I didn't look far enough into where this actually gets triggered in pam but this should help clear things up. You may also have setting that override the above in /etc/security/pam_env.conf as well as several other locations.

http://www.tuxradar.com/content/how-pam-works if you really want to get into how pam works and how to identify what programs use it.

Share:
6,694

Related videos on Youtube

Jarvin
Author by

Jarvin

Updated on September 17, 2022

Comments

  • Jarvin
    Jarvin over 1 year

    In Ubuntu the path variable is stored in /etc/environment. This is mine (I've made no changes to it, this is the system default):

    $ cat /etc/environment 
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    

    but when I examine my PATH variable:

    $ echo $PATH
    /home/dan/bin:/home/dan/bin:/bin:/usr/bin:/usr/local/bin:/usr/bin/X11
    

    You'll notice /usr/games is missing (it was there up until a few days ago). My /etc/profile makes no mention of PATH. My ~/.profile is the default and only has:

    if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
    fi
    

    This only happens in gnome, not in tty1-6. This is missing from both gnome terminal and when I try to call applications from the applications dropdown. Anyone know what could be causing this?

    Thanks.

  • Jarvin
    Jarvin almost 14 years
    Yes, I'm familiar with that solution, but that is a user level solution for a system level problem. I would actually like to address the problem. There are plenty of places I could just override the PATH variable, like /etc/profile as well, but that has nothing to do with PATH on Ubuntu, so I would prefer to address it where the problem lies.
  • badboy24
    badboy24 about 10 years
    Today I have the same problem as the OP: I rebooted and suddenly the correct PATH is no longer available in bash. It was yesterday. Something is actually broken...