1.在bash下运行:
echo $PATH > PATH=/home/xxx/bin:/home/xxx/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
2.$PATH在文件/etc/environment中被定义
cat /etc/environment > PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
3.在$HOME/.profile中有修改
> # set PATH so it includes user's private bin directories > PATH="$HOME/bin:$HOME/.local/bin:$PATH"
4.在/etc/profile.d/apps-bin-path.sh中有修改
> # Expand $PATH to include the directory where snappy applications go. > if [ "${PATH#*/snap/bin}" = "${PATH}" ]; then > export PATH=$PATH:/snap/bin > fi
准确的说,不同用户最终看到的$PATH是不同的
另:在/etc/login.defs有以下文字
> # > # *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
附送代码,运行有惊喜
#includeint main( int argc, char* argv[], char** envp) { while(*envp)` printf("%s\n", *(envp++));` return 0; }