login shell和non-login shell环境配置
2013-12-17 17:18
232 查看
一、测试场景
1、login shell 场景: 当系统启动时或你开启一个新的终端登录系统时,系统通过调用/bin/login程序处理登录并在一个shell中显示命令行提示符,这个shell就是login shell,也就是说通过用户名和密码登录的shell,例如:ssh远程登录以及图形界面登录(输入用户名和密码)
2、non-login shell 场景: 当用户直接在shell窗口中通过bash以及登录图形界面后打开的shell(CTRL+ALT+T)。
二、配置文件解析顺序
login shell :
1、全局(所有用户)设定 /etc/profile 只有login shell 才会读取
2、局部(依据用户)设定 ~/.bash_profile
~/.bash_login
~/.profile
其實 bash 的 login shell 設定只會讀取上面三個檔案的其中一個, 而讀取的順序則是依照上面的順序。也就是說,如果 ~/.bash_profile 存在,那麼其他兩個檔案不論有無存在,都不會被讀取。 如果 ~/.bash_profile 不存在才會去讀取 ~/.bash_login,而前兩者都不存在才會讀取 ~/.profile 的意思。(摘自鸟哥)
non-login shell:
局部(依据用户)设定: ~/.bashrc
當你取得 non-login shell 時,該 bash 設定檔僅會讀取 ~/.bashrc 而已啦(摘自鸟哥)。但是从父进程上继承过来的环境变量依然存在!
1、login shell 场景: 当系统启动时或你开启一个新的终端登录系统时,系统通过调用/bin/login程序处理登录并在一个shell中显示命令行提示符,这个shell就是login shell,也就是说通过用户名和密码登录的shell,例如:ssh远程登录以及图形界面登录(输入用户名和密码)
2、non-login shell 场景: 当用户直接在shell窗口中通过bash以及登录图形界面后打开的shell(CTRL+ALT+T)。
二、配置文件解析顺序
login shell :
1、全局(所有用户)设定 /etc/profile 只有login shell 才会读取
2、局部(依据用户)设定 ~/.bash_profile
~/.bash_login
~/.profile
其實 bash 的 login shell 設定只會讀取上面三個檔案的其中一個, 而讀取的順序則是依照上面的順序。也就是說,如果 ~/.bash_profile 存在,那麼其他兩個檔案不論有無存在,都不會被讀取。 如果 ~/.bash_profile 不存在才會去讀取 ~/.bash_login,而前兩者都不存在才會讀取 ~/.profile 的意思。(摘自鸟哥)
non-login shell:
局部(依据用户)设定: ~/.bashrc
當你取得 non-login shell 時,該 bash 設定檔僅會讀取 ~/.bashrc 而已啦(摘自鸟哥)。但是从父进程上继承过来的环境变量依然存在!
相关文章推荐
- login-shell 和 non-login shell 对环境配置文件的读取
- login shell和non-login shell环境配置、 环境变量的设置、查看
- 环境配置文件: login, non-login shell, /etc/profile, ~/.bash_profile, source, ~/.bashrc
- login shell和non-login shell
- login shell 和 non-login shell 的区别
- login shell与non-login shell的区别
- login shell与non-login shell的区别
- Linux中环境变量到底写在哪个文件中?解析login shell 和 no-login shell
- Linux下Bash的操作环境相关,issue,motd,login shell,non-login shell,source,stty,set
- bash 的环境配置 及文件读取流程(login shell 环境下)
- login shell和non-login shell
- 如何理解login shell 和non-login shell
- login shell和non-login shell的区别:
- login shell 和 non-login shell 的相关问题
- login shell vs non-login shell
- login shell non-login shell
- 关于ansible远程执行的环境变量问题(login shell & nonlogin shelll)
- login shell 和 non-login shell 的区别
- login shell 和non-login shell的区别
- Linux 每日一练习:Login Shell 与Non-login Shell