In general, every process inherits its environment (including a value for the PATH
) from its parent. So if you start a shell from a terminal emulator, the shell inherits from the terminal which inherits from the desktop session and so on. If you follow the process tree back, you will find that a default PATH
value is read from the /etc/environment
file by the pam_env module when a user's session is initiated.
Additionally, if you are using Windows Subsystem for Linux (WSL), path components may be inherited from the Windows host session via the appendWindowsPath
interoperability feature.
For the specific case of shells, the PATH
variable may additionally be set or modified by various system-wide and/or user-specific configuration files, depending on
- which shell you are using (bash, dash, ksh, zsh, csh etc.)
- how the shell is invoked (as a login shell, as an interactive non-login shell, or as a non-interactive shell)
For bash, you can read the details in the INVOCATION section of man bash
.