LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 70|回复: 2

关于bash配置文件的奇怪的问题

[复制链接]
发表于 2006-8-16 13:56:32 | 显示全部楼层 |阅读模式
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
...
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists


昨天我做了一件事情

[root@sarge ~]PATH=aaa
[root@sarge ~] env
-bash: env: command not found

这样以来,大部分命令都需要输入绝对路径。我exit退出后重新登陆了一遍,PATH就恢复原来的了。

我的问题是:
PATH是在/etc/profile中设定的,我改掉后为何重新登陆就恢复了?我的理解是应该是系统重新启动后才应该恢复。

环境debian3.1r0 init 2
发表于 2006-8-16 14:39:03 | 显示全部楼层
not sure what your question is... if you relogin back, login runs /etc/profile to setup the env for you then you get your default $PATH back.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-8-16 14:46:21 | 显示全部楼层
谢谢楼上,开始我理解错了。

/etc/profile这个文件,每次登陆的时候会加载一次。我误以为是系统启动的时候,用户登陆前加载一次。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表