tec*_*ack 11 linux root bash path
我PATH在 in 中添加了一个目录/etc/profile。这适用于我的用户帐户,但不适用于 root。将它添加到我的很容易,/root/.bashrc但我想了解有什么问题。这是一个大部分未修改的 Debian 6,所以我认为我的更改应该可以解决问题。
这是我的/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/lib/distcc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/lib/distcc/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "$PS1" ]; then
if [ "$BASH" ]; 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
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
Run Code Online (Sandbox Code Playgroud)
编辑:我添加的路径是distcc-stuff. 这是echo $PATH告诉我的:
$ echo $PATH
/usr/lib/distcc/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Run Code Online (Sandbox Code Playgroud)
您需要运行登录 shell(或运行非交互式 shell,但这不是您想要的)来加载/etc/profile.
用
su - username
Run Code Online (Sandbox Code Playgroud)
或者在root的情况下
su -
Run Code Online (Sandbox Code Playgroud)
去做这个。
-与-lor相同--login,并使外壳成为登录外壳。