当前位置: 技术问答>linux和unix
修改该登录脚本加入环境变量
来源: 互联网 发布时间:2016-07-30
本文导语: 大家好: 有一个比较初级的问题啊,我想让一个用户在登录的时候系统自动加入一个路径到PATH环境变量中,应该如何修改登录脚本啊,这个脚本在哪啊,谢了! | 在登录Linux时要执行文...
大家好:
有一个比较初级的问题啊,我想让一个用户在登录的时候系统自动加入一个路径到PATH环境变量中,应该如何修改登录脚本啊,这个脚本在哪啊,谢了!
有一个比较初级的问题啊,我想让一个用户在登录的时候系统自动加入一个路径到PATH环境变量中,应该如何修改登录脚本啊,这个脚本在哪啊,谢了!
|
在登录Linux时要执行文件的过程如下:在刚登录Linux时,首先启动 /etc/profile 文件,然后再启动用户目录下的 ~/.bash_profile、 ~/.bash_login或 ~/.profile文件中的其中一个,执行的顺序为:~/.bash_profile、 ~/.bash_login、 ~/.profile。如果 ~/.bash_profile文件存在的话,一般还会执行 ~/.bashrc文件。因为在 ~/.bash_profile文件中一般会有下面的代码: if [ -f ~/.bashrc ] ; then . ./bashrc fi ~/.bashrc中,一般还会有以下代码: if [ -f /etc/bashrc ] ; then . /bashrc fi 所以,~/.bashrc会调用 /etc/bashrc文件。最后,在退出shell时,还会执行 ~/.bash_logout文件。
所以,在/etc/profile里改对所有用户都有效
在~/.bash_profile里改,能够限制有效用户范围
所以,在/etc/profile里改对所有用户都有效
在~/.bash_profile里改,能够限制有效用户范围
|
我记得path是在/etc/profile里修改的
|
|
应该改:/etc/profile 是可以的:
wphndm1% more profile
#ident "@(#)profile 1.19 01/03/13 SMI" /* SVr4.0 1.3 */
# The profile that all logins get before using their own .profile.
trap "" 2 3
export LOGNAME PATH
if [ "$TERM" = "" ]
then
if /bin/i386
then
TERM=sun-color
else
TERM=sun
fi
export TERM
fi
# Login and -su shells get /etc/profile services.
# -rsh is given its environment in its .profile.
case "$0" in
-sh | -ksh | -jsh | -bash)
if [ ! -f .hushlogin ]
then
/usr/sbin/quota
# Allow the user to break the Message-Of-The-Day only.
trap "trap '' 2" 2
/bin/cat -s /etc/motd
trap "" 2
/bin/mail -E
case $? in
0)
echo "You have new mail."
;;
2)
echo "You have mail."
;;
esac
fi
esac
umask 022
trap 2 3
#### BEGIN OF SCbrkseq ####
/usr/sbin/prtconf -F 2>/dev/null 1>/dev/null
if [ $? -ne 0 ] && [ -x /export/opt/SCbrkseq/bin/autoexit ]
then
/export/opt/SCbrkseq/bin/autoexit -d console -m
fi
#### END OF SCbrkseq ####
PATH=$PATH:/opt/samba/lib:
export PATH LD_LIBRARY_PATH
. /etc/emc/bin/emcp_setup.sh
wphndm1% more profile
#ident "@(#)profile 1.19 01/03/13 SMI" /* SVr4.0 1.3 */
# The profile that all logins get before using their own .profile.
trap "" 2 3
export LOGNAME PATH
if [ "$TERM" = "" ]
then
if /bin/i386
then
TERM=sun-color
else
TERM=sun
fi
export TERM
fi
# Login and -su shells get /etc/profile services.
# -rsh is given its environment in its .profile.
case "$0" in
-sh | -ksh | -jsh | -bash)
if [ ! -f .hushlogin ]
then
/usr/sbin/quota
# Allow the user to break the Message-Of-The-Day only.
trap "trap '' 2" 2
/bin/cat -s /etc/motd
trap "" 2
/bin/mail -E
case $? in
0)
echo "You have new mail."
;;
2)
echo "You have mail."
;;
esac
fi
esac
umask 022
trap 2 3
#### BEGIN OF SCbrkseq ####
/usr/sbin/prtconf -F 2>/dev/null 1>/dev/null
if [ $? -ne 0 ] && [ -x /export/opt/SCbrkseq/bin/autoexit ]
then
/export/opt/SCbrkseq/bin/autoexit -d console -m
fi
#### END OF SCbrkseq ####
PATH=$PATH:/opt/samba/lib:
export PATH LD_LIBRARY_PATH
. /etc/emc/bin/emcp_setup.sh