0

In summary, there are entries in my $PATH that i don't know where they are added. Help!

My general question is: At which places is my $PATH variable modified when starting up a terminal? My specific question is, where the /usr/local/games folder is introduced to my $PATH variable.

What i found out ('believe') so far: in /etc/login.defs the first definition of $PATH occurs. By default the games folders are added here, but they remain persistent when i remove them at this place. I have the following lines in there:

# *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
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin # note i removed games here

then there is /etc/environment which i am not yet sure when it comes into play and how it relates to logins.defs. It reads

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

then, as nicely presented in the answers to this and this question, there are ~/.profile and ~/.bashrc, both of which i control very well. The latter contains the two lines

PATH=${PATH/":/usr/games"/""} # remove games from $PATH
PATH=${PATH/":/usr/local/games"/""}

when out-commented, the two games folders appear in my $PATH. So, where do these two folders come from? what places are parsed where the $Path variable is modified on startup?

  • /etc/profile – bac0n Mar 26 at 14:56
0

By default, /etc/environment, which is read at login, includes both /usr/games and /usr/local/games. So it looks like you edited that file also, which ought to be sufficient to drop those directories. It's unclear to me why you would need to involve ~/.profile and/or ~/.bashrc for the purpose.

Edit:

The above is based on how it works on standard Ubuntu. It's possible that the WSL default setup is slightly different.

| improve this answer | |
  • i included ~/.profile and ~/.bashrc here because they seem to be referenced in most "how to add folder to $PATH"-tutorials. – Dr-Nuke Mar 26 at 15:22
  • @Dr-Nuke: Fair enough. Given the info you gave, I can't tell how the games folders are added on your system. – Gunnar Hjalmarsson Mar 28 at 3:26

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.