/etc/profile、/etc/profile.d、/etc/bashrc、~/bash_profile、~/bashrc的做用和执行顺序

bash的配置文件:shell

  1. 按生效范围划分:

              全局配置:/etc/profile和/etc/profile.d(/etc/profile.d是个目录,里面存放的是以.sh结尾的   shell脚本文件)bash

              我的配置:~/bash_profile和~/bashrc变量

     2. 按功能划分:配置

                profile类:为交互式登录的shell提供配置(定义环境变量、须要执行的脚本);file

                bashrc类:为非交互式登录的shell提供配置(定义别名、本地变量);终端

 

shell登录:交互式登录、非交互式登录密码

  1. 交互式登录:  

            1. 直接经过终端输入帐号密码登录;im

            2. 使用su - UserName或su -l UserName或su --login UserName登录;经过man su查看命令,   以下图:可知会初始化环境变量。配置文件

                

      2. 非交互式登录:脚本

              1. su UserName;

              2. 图形界面下打开的终端;

              3. 执行脚本;

 

交互式登录的执行流程:/etc/profile ---> /etc/profile.d ---> ~/bash_profile ---> ~/bashrc ---> /etc/bashrc。

非交互式登录的执行流程:~/bashrc ---> ~/bash_profile ---> /etc/profile.d/*.sh

相关文章
相关标签/搜索