When I launch a terminal in ubuntu I get following path on echo $PATH


I want to remove those paths with games keyword from my $PATH , but I couldn't find from where the path like /usr/games , /user/local/games , /usr/sbin are set.

I tried to grep by grep xxx ~/.* -l

This gives files which set /usr/bin , /usr/local/bin etc..

But not for the above mentioned games and sbin paths. How do I find from where it's set?

2 Answers 2


There are several places it could be set. To start with, it can be set in one or more of the following:

  • any shell profile script (e.g. ~/.bashrc, /etc/profile, /etc/bash.bashrc, /etc/profile.d/*, etc)
  • /etc/login.defs
  • /etc/security/pam_env.conf
  • /etc/environment
  • $HOME/.pam_environment

If it is not set in your personal environment, then it is set for every user. That means somewhere under /etc. Go to /etc and issue:

grep usr.games * */* */*/* 2> /dev/null

On an Ubuntu installation, that will give you:

login.defs:ENV_PATH     PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
manpath.config:MANPATH_MAP      /usr/games              /usr/share/man

The passwd files are for the user games, so of no importance. manpath is for reading the manuals. So, is you remove it from environment and login.defs, your gaming-days are over.

  • So to remove games entries from the PATH I should the remove the lines starting with games from the passwd file? I tried that, but it keeps coming back. Jun 20 at 12:20
  • No. it is where the PATH is set that you need to look at. Jun 20 at 13:36
  • I don't see it getting added to PATH in any of the files listed in cas's answer. Where else could it be getting added to PATH? Jun 20 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .