Linux 的环境配置文件主要可以分为两种profile 和 bashrc 文件,profile 文件又分为:"/etc/profile","~/.bash_profile";bashrc 文件则又分为 "/etc/bashrc",和 “~/.bashrc"文件。
1.在这之前首先了解login shell 和 non-login shell
Login shell :指的是我们用xhell等其他连接软件远程登陆时(需输入用户名和密码)或使用su - 命令时,都属于login shell
一般来说,login shell 加载的只有/etc/profile文件和~/.bash_profile
先查看一下~/.bash_profile文件的内容
这个文件 if ... then ... 那一段! 该段的内容指的是判断家目录下的 ~/.bashrc 存在否,若存在则读入 ~/.bashrc 的配置
再观察~/.bashrc的文件内容
我们可以知道在该文件中,最后会读取/etc/bashrc文件的配置
2.在我们使用su命令跳转用户时,而非使用su - ,此时就属于non-login shell
non-login shell 则只会加载~/.bashrc文件和/etc/profile文件,还包括~/.bashrc下的子文件如上图。