Linux source command & bashrc/ profile

来源:互联网 发布:mac哑光修容粉怎么选 编辑:程序博客网 时间:2024/05/04 16:14

Source command is used to compile some critical instructions. Like the instructions in bashrc or profile. 


The bashrc and profile files are used to run some important instructions once you open your terminal. 


However, there are two kinds of bashrc or profile files which are located in two folders. 


The first kind is located in the /etc folder. The files locate in this folder are to set the global environment. 


The second kind is located in the ~ folder. It is to set the private environment of a particular user. 


Extended reading:


Login shell vs non-login shell[forward]


交互式模式就是shell等待你的输入,并且执行你提交的命令。这种模式被称作交互式是因为shell与用户进行交互。这种模式也是大多数用户非常熟悉的:登录、执行一些命令、签退。当你签退后,shell也终止了。 shell也可以运行在另外一种模式:非交互式模式。在这种模式下,shell不与你进行交互,而是读取存放在文件中的命令,并且执行它们。当它读到文件的结尾,shell也就终止了。


We used the bashrc or profile for non-login shell.


A nice summary(forward):


当登入系统时候获得一个shell进程时,其读取环境设定档有三步
1首先读入的是全局环境变量设定档/etc/profile,然后根据其内容读取额外的设定的文档,如
/etc/profile.d和/etc/inputrc
2然后根据不同使用者帐号,去其家目录读取~/.bash_profile,如果这读取不了就读取~/.bash_login,这个也读取不了才会读取
~/.profile,这三个文档设定基本上是一样的,读取有优先关系
3然后在根据用户帐号读取~/.bashrc
至于~/.profile与~/.bashrc的不区别
都具有个性化定制功能
~/.profile可以设定本用户专有的路径,环境变量,等,它只能登入的时候执行一次
~/.bashrc也是某用户专有设定文档,可以设定路径,命令别名,每次shell script的执行都会使用它一次


Reference:


http://www.cnblogs.com/hongzg1982/articles/2101792.html


0 0