bashrc,bash_profile等shell配置文件详解
2015-01-26 12:20
281 查看
一、bashrc,bash_profile等文件执行顺序
如何确定这些文件的执行顺序呢? 最好的方法就是在这些文件的开头添加一个输出语句,这样文件一执行马上就会输出内容。我们首先在/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc,~/.bash_logout文件开头添加以下行:
为什么不添加到文件尾部?因为这些文件可以执行,在执行过程中会调用其它文件,如果以上语句添加到文件尾部,则可能被调用的文件好像在前面执行,这就会发生错误。
修改/tmp/bashseq文件权限, 使所有用户可写:
如下图所示:
将当前用户logout,重新login, 再查看/tmp/bashseq文件,内容如下:
二、各个文件作用
清空/tmp/bashseq文件, 使用普通用户登录, 查看/tmp/bashseq文件,内容如下:由此可见,上面四个文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc中:
前两件是全局的,每一个用户登录都会执行
后两个是专用的,针对特定用户设定.
再来看看~/.bash_profile,~/.bashrc这两个文件
.bash_profile内容:
.bashrc内容:
三、总结
讲到这里,你应该知道了如何对bashrc,bash_profile,bash_profile进行解析了。这些文件的界限并非十分明确,但是用户和全局必须分清。掌握这些内容,有助于编写shell script,也有助于对系统进行配置。四、参考文章
.bash_profile和.bashrc的什么区别转载自:http://www.jsxubar.info/bashrc-bash_profile.html
相关文章推荐
- 环境配置文件: login, non-login shell, /etc/profile, ~/.bash_profile, source, ~/.bashrc
- bash配置文件/etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc详解及修改PATH环境变量
- 关于shell启动时调用的几个配置文件/etc/profile .profile .bash_profile .bashrc等
- shell的初始化文件:/etc/profile和/etc/bashrc(bash.bashrc)
- 环境配置文件 ① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc
- 环境配置文件 ① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc 作用与执行顺序,以及与login/nonlogin关系
- Linux下文件 ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 的区别 | 用户登录后加载配置文件的顺序
- unix用户的配置文件 .bash_profile和.bashrc
- shell的初始化文件:/etc/profile和/etc /bashrc(bash.bashrc)
- [alpha]linux 启动配置文件:bash_profile 和 bashrc的区别
- shell的初始化文件:/etc/profile和/etc /bashrc(bash.bashrc)
- linux shell对应的配置文件是怎么被执行的呢?-----聊聊/etc/profile, ~/.bash_profile, ~/.bashrc等配置文件的执行流程
- shell的初始化文件:/etc/profile和/etc/bashrc(bash.bashrc)
- shell登录时的环境是如何配置的呢?—— bashrc、profile、bash.bashrc关系
- Linux下文件 ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 的区别 | 用户登录后加载配置文件的顺序
- 环境配置文件 ① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc
- 配置文件.profile,.login,.bash_profile和.bashrc的区别
- Linux 配置文件 启动文件rc.local、/etc/bash.bashrc、~/bashrc、/etc/profile、~/.profile加载顺序
- Linux下配置文件 /etc/profile、/etc/bashrc、~/.bash_profile、~/.profile、~/.bashrc 总结
- Linux环境配置文件 /etc/profile ~/.bash_profile ~/.bashrc /etc/bashrc的区别