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

开篇词

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 管理员手册:既简单又深刻

发布了103 篇原创文章 · 获赞 6 · 访问量 5053

猜你喜欢

转载自blog.csdn.net/stevenchen1989/article/details/104121079