如何设置这样的环境变量

最大的社区版本,Ubuntu的发源地
回复
罗非鱼
帖子: 980
注册时间: 2008-04-12 12:44

如何设置这样的环境变量

#1

帖子 罗非鱼 »

我的系统,
sudo find / -name 'pppoeconf'
/usr/sbin/pppoeconf
/usr/share/menu/pppoeconf
/usr/share/doc/pppoeconf

我输入pppoeconf,提示找不到命令。

于是我打开,sudo gedit /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" ]; 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

我使用sudo cp /usr/sbin/pppoeconf /usr/bin/pppoeconf
然后使用pppoeconf,可以执行了,

现在我想知道,可否直接编辑 /etc/profile,达到同样的效果,请问,如何编辑这个文件?
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: 如何设置这样的环境变量

#2

帖子 leeaman »

你把那两个PATH弄成一样就可以了
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
罗非鱼
帖子: 980
注册时间: 2008-04-12 12:44

Re: 如何设置这样的环境变量

#3

帖子 罗非鱼 »

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

这段修改成
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
export PATH
这样做,会有什么不良结果?
回复