shell加载配置文件
shell有不同的启动方式,根据启动方式的不同会加载不同的配置文件,从而配置不同的环境变量 我们比较常见的启动方式有: 1.通过linux控制台登录或者ssh方式,启动shell,这种情况为登录式启动shell 会依次加载/etc/environment, /etc/profile, ~/.bash_profile (或者~/.bash_login 或者 ~/.profile) 而~/.bash_profile中又会加载~/.bashrc,而~/.bashrc又加载 /etc/bashrc , /etc/bashrc又加载 /etc/profile.d/*.sh 2. 通过bash -l 登录式启动shell,会加载 /etc/profile, ~/.bash_profile 但不会加载/etc/environment 3,通过bash 非登录式启动shell,会加载~/.bashrc,前面说过~/.bashrc脚本又会加载/etc/bashrc , /etc/bashrc又加载 /etc/profile.d/*.sh 可以看出上面的三种方式,不管时登陆时还是非登陆时,都会加载~/.bashrc, /etc/bashrc , /etc/profile.d/*.sh中的内容 而 /etc/profile, ~/.bash_profile只有在登录式启动的时候才会加载