1.本地变量

 赋值: name=value

 引用: ${name},$name

 删除: uset

 作用域: 当前shell有效,不作用与同级shell和子shell,子shell可  由当前命令行输入bash生成

2.环境变量

 赋值: (1)export name=value

     (2)name=value

       export name

     (3)declare -x name=value

 作用域: 当前shell和子shell

 查看: export,declare -x,printenv,env

 删除: unset

3.只读变量

 赋值: (1)readolny name=value

     (2)declare -r name=value


4.profile配置文件

 触发方式: 交互式shell,通过账号密码登录,或使用su -l登录

 全局: /etc/profile,/etc/profile.d/*.sh

 个人: ~/.bash_profile

 作用: 定义环境变量或运行命令脚本

5.bashrc配置文件

 触发方式: 非交互式shell,使用su切换登录

 全局: /etc/bashrc

 个人: ~/.bashrc

 作用: 定义本地变量和别名

6.读取顺序

 交互shell:(1)/etc/profile 

        (2)/etc/profile.d/*.sh 

        (3)~/.bash_profile  

        (4)~/.bashrc 

        (5)/etc/bashrc 

 非交互式shell:(1)~/.bashrc

        (2)/etc/bashrc

        (3)/etc/profile.d/*.sh