32. Bash Shell - 启动时加载文件

拥有回忆 提交于 2020-01-31 12:08:39

开篇词

Bash 的启动配置文件可以帮我们预加载一些其他脚本文件并预设常见以及必要的变量。
Bash 提供了两类启动文件,一类是登录时加载,另一类是非登陆加载。
 

登陆 Shell 启动文件

登录时加载的启动文件有:

全局启动文件

cat /etc/profile    # 全局启动文件,Debian(Ubuntu) 以及 Redhat(CentOS) 分发版

打印出 CentOS 7 分发版 /etc/profile 文件的部分内容
打印 Ubuntu 18 分发版 /etc/profile 文件的部分内容

特定用户启动文件

cat ~/.bash_profile    # RedHat(CentOS)分发版

打印 CentOS 7 分发版 ~/.bash_profile 文件的部分内容

cat ~/.profile    # Debian(Ubuntu) 分发版

打印 Ubuntu 18 分发版 ~/.profile 文件的部分内容

cat ~/.bash_login    # Debian(Ubuntu) 以及 RedHat(CentOS) 分发版

 

非登陆 Shell 启动文件

启动文件将会在用户进入 Bash Shell 时加载:

cat /etc/bashrc    # Redhat(CentOS) 分发版

打印 CentOS 7 分发版 /etc/bashrc 文件的部分内容

cat ~/.bashrc    # Debian(Ubuntu) 与 RedHat(CentOS) 分发版

打印 CentOS 7 分发版 ~/.bashrc 文件的部分内容
打印 Ubuntu 18 分发版 ~/.bashrc 文件的部分内容
 

我所撰写的英文版本

32. Bash Shell - Startup Files
 

引用

参见

想看手册的其他内容?请访问该手册的所属专栏:《Linux 管理员手册:既简单又深刻

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!