LinuxEye - Linux系统教程

LinuxEye - Linux系统教程

当前位置: 主页 > Linux教程 >

bash配置文件login shell和非login shell

时间:2015-01-18 12:34来源:opstool.com 编辑:opstool 点击:
影响到bash环境变量的文件 下面这些文件都会对Bash的环境变量有影响 /etc/ bashrc / etc / profile ~ /.bashrc~/ . bash_profile bash之login shell、非login shell bash进程产生的场景 login shell 非login shell ssh登
影响到bash环境变量的文件
下面这些文件都会对Bash的环境变量有影响
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile

bash之login shell、非login shell

bash进程产生的场景 login shell 非login shell
ssh登录 Y N
su - 切换到用户 Y N
tmux新建窗口 Y N
screen新建窗口 N Y
ssh 远程执行 /bin/bash 脚本 N Y

bash配置文件的生效场景

shell类型 /etc/profile 和 ~/.bash_profile /etc/bashrc 和 ~/.bashrc
login shell 有效 有效(~/.bash_profile一般会source ~/.bashrc)
非login shell 无效 有效

bash初始化配置应该写在哪里
对于Redhat和CentOS系列的系统,/etc/bashrc和~/.bashrc在login shell 和非login shell的情景下都会被执行到。
如果想要环境变量在login shell和非login shell的场景下都被执行到,最佳的配置写入位置是~/.bashrc

转载请保留固定链接: https://linuxeye.com/Linux/2101.html

------分隔线----------------------------
标签:bash
栏目列表
推荐内容