启动bash shell 的几种方式

交互式shell

1.登录时作为默认登录shell 文本模式下输入用户名和密码的默认shell

读取bash主配置文件 /etc/profile

读取用户个性化设置 

$HOME/.bash_profile

$HOME/.bash_login

$HOME/.profile

不同系统选取的配置文件不一样,三个文件选一个进行配置

2.非登录交互shell 图像模式下 每次启动shell实例

不会读取 /etc/profile

读取 $HOME/.bashrc

非交互式shell

1.运行脚本的非交互式shell

启动时检查 BASH_ENV环境变量,一般都没有设置

 文件执行顺序

  /etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout

原文地址:https://www.cnblogs.com/loongqiang/p/3416655.html