Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The default value of the PATH environment variable in Ubuntu (13.10, at least) for an administrator (user in the sudo group) after logging in to the desktop environment is:

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

/usr/local/sbin and /usr/local/bin appear before /usr/sbin and /usr/bin. However, /usr/local/games appears after /usr/games.

Is there a reason for this? Or it's just a typo?

More information

  • Normal/administrator user's default PATH after logging with su - user:

    /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    
  • Normal/administrator user's default PATH after logging in a virtual console:

    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    
  • Default PATH for the root user (after logging in with sudo -i; I haven't tried enabling the root user and logging in through a virtual console):

    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    
  • Content of /etc/environment:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    
  • Relevant line of /etc/sudoers:

    Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    
  • Relevant lines of /etc/login.defs:

    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
    

Repeating the main question: what's the reason for /usr/local/games to appear after /usr/games, instead of before, in the default PATH?

And a related question: from where does the value of PATH come from? It seems /etc/environment and /etc/login.defs are both used in different situations.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

I can't come up with any reason other than: it's a mistake.

From what I can see, /usr/local/games is a fairly late addition to /etc/environment. A 12.04 machine of mine does not have it.

I was really struggling to find where /etc/environment comes from. Turns out it's not a file that's packaged, it's created at install time (I assume to prevent it harming existing configurations during upgrades). Thanks to this answer on Unix.SE, we can see that it's coming from libpam-modules's postinst script.

# Add PATH to /etc/environment if it's not present there or in
# /etc/security/pam_env.conf
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" lt 1.1.3-7ubuntu3; then
        if ! grep -qs ^PATH /etc/security/pam_env.conf; then
                if ! grep -qs ^PATH= /etc/environment; then
                        echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"' >> /etc/environment
                elif ! grep -qs "^PATH=.*/usr/local/games" /etc/environment; then
                        sed -i '/^PATH=/ s,:/usr/games,:/usr/games:/usr/local/games,g' /etc/environment
                fi
        fi
fi

So yeah, I'd suggest reporting a bug against pam.

share|improve this answer
    
That's what I thought: a mistake/typo. Thank you for your answer! And thank you for finding out from where /etc/environment comes from, so now I/we can report a bug against a specific package! I'll report the bug and mark the accepted answer later today (in a few hours). –  Bruno Nova Feb 18 at 14:19
2  
@BrunoNova My Debian has it in the correct order, so should be something specific to Ubuntu. –  Braiam Feb 18 at 14:34
1  
@Braiam That's odd because the postinst scripts for the Debian Sid version and the Ubuntu Trusty version are completely different (though the installed files are nigh-on the same). Where is Debian sourcing its copy of PATH in /etc/environment? Could you have a look around? –  Oli Feb 18 at 14:51
    
grep -C 5 "/etc/environment" /var/lib/dpkg/info/* should help. –  Oli Feb 18 at 14:51
1  
I reported the "bug": bugs.launchpad.net/ubuntu/+source/pam/+bug/1281802 –  Bruno Nova Feb 18 at 21:49
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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