日期:2014-05-16  浏览次数:20705 次

UNIX中为什么重启或者注销之后,之前插入的环境变量PATH的值恢复到启动前的状态
如题。
也就是说,之前插入的值不见了。
求解

------解决方案--------------------
你之前是用export设的环境变量吧,这种环境变量在再一次登录的时候就会失效的。更改profile文件才能使环境变量持续有效
------解决方案--------------------
C/C++ code

# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

------解决方案--------------------
不要用export设置环境变量,只对当此有效,在/etc/profile文件中配置你的环境变量。这样才能每次都生效。
# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...


------解决方案--------------------
探讨

如何修改,我的etc/profile中是这样子的。
C/C++ code

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
[ -……

------解决方案--------------------
没有加到.profile 里就可以了,要生效source .profile
------解决方案--------------------
change /etc/profile or /etc/profile.local ?