Linux

来源:互联网 发布:家庭网络布线公司 编辑:程序博客网 时间:2024/06/06 08:45

在使用Linux的过程中,一直搞不清楚/etc/rc.local, /etc/profile, /etc/bashrc 这个文件的用处。现在稍微有点眉目,特此记录一下


关于/etc/profile文件,这里又引入了login shell与no login shell的概念

1、登入shell

/etc/profile 是登入shell启动后运行的第一个启动脚本,它只为登入shell运行

登入shell加载启动脚本的顺序为:/etc/profile → /etc/profile.d → .bash_profile → .bashrc → /etc/bashrc

每个调用的脚本会依次撤销前一个调用脚本中的改变

在退出登入shell时,我们还可以执行某些任务,如创建自动备份、清除临时文件,这些任务放在.bash_logout文件中

2、非登入shell

非登入shell加载启动脚本的顺序.bashrc → /etc/bashrc → /etc/profile.d


关于rc.local:

官方的解释为:rc.local is a file, owned by root.root and should be mode 755. The rc.local file is for initialization of programs after the system has fully booted. This script is run right before login prompts are displayed. You can use the file to run last minute startups, set certain environment variables, etc.

表明:该脚本运行在操作系统启动之后,在登录login shell之前。如果环境变量在/etc/profile中配置的话,那么在启动/etc/rc.local脚本时就会找不到环境变量


等完全搞懂,再行补充

0 0