bash环境变量配置

bash的配置文件

按生效范围划分
    全局配置:
        /etc/profile
        /etc/profile.d/*.sh
        /etc/bashrc
    个人配置:
        ~/.bash_profile
        ~/.bashrc
按功能划分,存在两类
    profile类:为交互式登录的shell提供配置
        全局:/etc/profile,/etc/profile.d/*.sh
        个人:~/.bash_profile
        功能:
            用于定义环境变量
    运行命令或脚本
    bashrc:非交互式
      全局:/etc/bashrc
      个人:~/.bashrc
       功能:
            定义命令别名
       定义本地变量

    shell登录:
       交互式登录:
       直接通过终端输入账号密码登录
       使用“su - username”或“su -l username”切换用户
             /etc/profile --> /etc/profile.d/*.sh --> ~/.bash_profile -->~/.bashrc --> /etc/bashrc(越往后越高)

            非交互式:
            su username
            图形界面下打开的终端
            执行脚本
            ~/.bashrc --> /etc/bashrc -->etc/profile.d/*.sh


编辑配置文件生效的方式
重启shell进程
source 配置文件名: 例:source /.bashrc

posted @ 2018-04-15 16:41  whz_it  阅读(380)  评论(0编辑  收藏  举报