关于shell启动时调用的几个配置文件/etc/profile .profile .bash_profile .bashrc等
来源:互联网 发布:java程序结构分为 编辑:程序博客网 时间:2024/05/25 12:21
linux下以.开头的文件为隐藏文件,今天和同事探讨了下.profile,查了下资料,记录一下。
原帖:http://www.linuxdiyf.com/bbs/thread-312980-1-1.html
当用户输入帐号密码登录一个用户终端的时候,那么,首先,系统会读取文件/etc/profile,加载其中的配置,/etc/profile这个文件又会调用几个文件,包括/etc/sysconfig/i18n这个文件用来设置终端的语言信息,/etc/inputrc这个文件主要设置终端的输入方式,比如Ctrl+C之类的情况,还有一个比较重要的就是/etc/profile.d/目录下的脚本文件,那么如果真的需要修改一些全局的bash环境的话,最好是将环境写成一个shell脚本,放在/etc/profile.d/目录中,那么登录的时候,/etc/profile会自动去调用。
那么,上面说到的是用户登录的时候 ,执行的全局文件,那么在自己的家目录下,还会执行个人的shell配置文件,主要有.bash_profile,.bash_login,.profile这三个文件,一般情况下,你的家目录下应该只有.bash_profile这个文件,因为系统只执行这三个文件中的一个,如果没有找到.bash_profile,才会继续搜索.bash_login,没有的话,搜索.profile。
用vim编辑器打开.bash_profile,可以看到,这个文件又会调用~/.bashrc这个文件,可以看到一些alias设置,所以,如果你需要设置你自己个人的一些alias和一些环境变量的时候,强烈建议写在这个文件中或者~/.bash_profile中。但是还是写在~/.bashrc中比较好,为什么呢?因为有一种情况,比如你在X window下,直接开启一个命令行终端的话,是不用输入帐号密码登录的,都有印象吧,那么在这个情况下,实际上是不会去读取/etc/profile,~/.bash_profile这些文件的,而是直接读取./bashrc这个文件,所以,如果你想你的环境设置在任何时候都有效的话,建议写入这个文件。
最后再提一点,那么看~/.bashrc这个文件中的内容,可以看到,这个文件其实还会调用/etc/bashrc文件的内容,用vim打开/etc/bashrc这个文件看看,会发现在这个文件的最后又会调用/etc/profile.d/里面的sh文件,呵呵,很有趣吧~~~其实Linux中很多都是这样,最后都是殊途同归,到一个文件中。
下面这篇文章给出了终端配置的修改方法
http://blog.csdn.net/louiswang2009/article/details/5886575
- 关于shell启动时调用的几个配置文件/etc/profile .profile .bash_profile .bashrc等
- 关于bash启动脚本/etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc的区别
- 几个profile, bashrc, bash_profile等文件
- .bashrc,profile,.bash_profile等几个文件用途
- linux shell对应的配置文件是怎么被执行的呢?-----聊聊/etc/profile, ~/.bash_profile, ~/.bashrc等配置文件的执行流程
- bash_profile、bashrc、/etc/profile的关系
- ~/.bashrc, ~/.bash_profile 以及/etc/profile /etc/bashrc 几个文件的区别与相互关系
- 浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 的区别
- Linux下/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc的区别
- /etc/profile、/etc/bashrc、.bash_profile和.bashrc的区别
- /etc/profile,/etc/bashrc,~/.bash_profile,~/.bashrc,~/.bash_logout的区别
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 四文件的区别
- ~/.bashrc 和 ~/.bash_profile 和 /etc/bashrc 和 /etc/profile 脚本的区别和启动加载顺序
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
- /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 比较
- /etc/profile /etc/bashrc ~/.bash_profile ~/.bashrc 区别
- 根据账号个数生成8位随机密码
- 关于Spring中的<context:annotation-config/>配置
- (原创)Android studio--Libs导入(已解决)
- C++ 重载关系操作符
- 您没有感觉到,当今时代工作生活真的很累么?
- 关于shell启动时调用的几个配置文件/etc/profile .profile .bash_profile .bashrc等
- PB 数据窗口数据导入Excel, 如果存在则追加,不存在则创建。
- hdu3247 Resource Archiver AC自动机+状态压缩DP
- 就是简单的创建十个目录,在目录下创建与目录同名的文件加上文件创建的次数
- JAVA连接ACCESS数据库
- 把一个字符串赋值给一个数组
- android 新浪微博SDK 3.0.1分享
- WebService接口调用
- linux LCD驱动(二)--FrameBuffer