shell登录时的文件执行顺序
2017-03-28 19:08
453 查看
序
想必大家都在linux系统中设置过环境变量,有没有感觉不知道应该在哪个文件里面设置呢?比如~/.profile, ~/.bash_profile, ~/.bashrc , /etc/profile , 等等。
其实这些文件会在不同的场景下被运行。
shell分为login shell , non-login shell , interactive shell , non-interactive shell 。
比如当你ssh example.com之后,获取的就是interactive login shell ,
当你ssh example.com "uptime" , 获取的就是non-interactive login shell ,
当你在登录的机器上su user之后,获取的就是interactive non-login shell,
当你在登录的机器上su - user之后,获取的就是interactive login shell 。
下面是在不同场景下执行文件的先后顺序,A, B, C表示先执行A,再执行B,再执行C。
B1,B2,B3表示按顺序找文件,先找到谁就只执行谁。
链接 https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
想必大家都在linux系统中设置过环境变量,有没有感觉不知道应该在哪个文件里面设置呢?比如~/.profile, ~/.bash_profile, ~/.bashrc , /etc/profile , 等等。
其实这些文件会在不同的场景下被运行。
shell分为login shell , non-login shell , interactive shell , non-interactive shell 。
比如当你ssh example.com之后,获取的就是interactive login shell ,
当你ssh example.com "uptime" , 获取的就是non-interactive login shell ,
当你在登录的机器上su user之后,获取的就是interactive non-login shell,
当你在登录的机器上su - user之后,获取的就是interactive login shell 。
下面是在不同场景下执行文件的先后顺序,A, B, C表示先执行A,再执行B,再执行C。
B1,B2,B3表示按顺序找文件,先找到谁就只执行谁。
+----------------+-----------+-----------+------+ | |Interactive|Interactive|Script| | |login |non-login | | +----------------+-----------+-----------+------+ |/etc/profile | A | | | +----------------+-----------+-----------+------+ |/etc/bash.bashrc| | A | | +----------------+-----------+-----------+------+ |~/.bashrc | | B | | +----------------+-----------+-----------+------+ |~/.bash_profile | B1 | | | +----------------+-----------+-----------+------+ |~/.bash_login | B2 | | | +----------------+-----------+-----------+------+ |~/.profile | B3 | | | +----------------+-----------+-----------+------+ |BASH_ENV | | | A | +----------------+-----------+-----------+------+ | | | | | +----------------+-----------+-----------+------+ | | | | | +----------------+-----------+-----------+------+ |~/.bash_logout | C | | | +----------------+-----------+-----------+------+
链接 https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
相关文章推荐
- Shell登录类型,以及读取配置文件的顺序
- 登录和退出时shell的执行顺序
- linux shell和配置文件的执行顺序
- 简易登录,批量执行命令,批量copy文件shell脚本【Linux运维之道之脚本案例】 推荐
- 登录和退出时shell的执行顺序
- 登录式shell与非登录式shell的文件自动执行顺序
- linux登录时/etc/profile和/etc/bashrc等文件执行顺序和过程
- 简易登录,批量执行命令,批量copy文件shell脚本【Linux运维之道之脚本案例】
- [zz]登录Linux时/etc/profile、~/.bash_profile等几个文件的执行过程
- shell基础67:执行顺序(||及&&,{}及())及正则表表达式
- 网页中使用 Wscript.Shell 执行文件
- 转载:nginx配置文件的location标签执行顺序和反向代理配置
- Linux_shell_命令执行的顺序
- 动态加载JS文件,完美解决跨域、编码、嵌套、队列、兼容性、执行顺序等相关问题。
- 命令执行顺序-------shell学习(5)
- shell执行目录下文件,找出指定错误
- MySQL命令行 不同端口登录 执行SQL文件 创建用户 赋予权限 修改root密码
- 登录Linux时/etc/profile、~/.bash_profile等几个文件的执行过程
- 使用bat文件顺序执行多个应用程序
- 关于登录linux时,/etc/profile、~/.bash_profile等几个文件的执行过程