按生效范围划分: 全局配置文件:/etc/profile 调用 /etc/profile.d/*.sh

/etc/profile.d/*.sh

用户配置文件: ~/.bash_profile  调用      ~/.bashrc

~/.bash_profile 一般配置用户环境变量 ~/.bashrc 一般配置用户别名

按功能划分: profile 类:为交互式登录的shell 提供配置 用于定义环境变量,运行命令和脚本 全局:/etc/profile /etc/profile.d/*.sh 用户:~/.bash_profile bashrc类: 为非交互式登录的shell提供配置 用于定义命名别名,本地变量 全局:/etc/bashrc 用户:~/.bashrc 登录式shell 与 非登录式shell

登录式shell       需要用户名密码输入
	         登录图型化
              登录文本tty终端
              远程登录如ssh,telnet
              su - 

执行顺序:/etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc

非登录式      不需要用户名密码输入
         	su  
            执行shell脚本
            在已登录的图型介面打开终端 

执行顺序:~/.bashrc --> /etc/bashrc --> /etc/profile.d/*.sh

通过编辑修改的配置文件生效方式:

  • 1、退出并重新登陆
  • 2、让bash 重读此配置文件 **source 和 . 在当前shell下执行来自文件的命令。 使用脚本执行 是在子shell下执行命令,那么父shell是无法继承来自脚本中的变量 **