Why is /usr/local/games after /usr/games in the default PATH?

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.


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.