这是我的整个 /etc/profile。
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "${PS1-}" ]; then
if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "$(id -u)" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
根据文件,我的$PATH
应该是/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root,/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
如果不是。然而,我的实际情况$PATH
有所不同。
daniel@debian:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
root@debian:/# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
My$PATH
固定为/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
不考虑权限,与 中写入的不同/etc/profile
。为什么会出现差异?我该如何纠正这个问题?
答案1
路径线
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
仅对 UID 0(即 root)有效。