天下

记录修行的印记

理解login shell和non-login shell

理解login shell和non-login shell

用户交互式login的时候,就会初始化profile相关的脚本,这就是所谓的login shell。

当在已经存在的shell里面启动另外一个shell的时候,比如使用"bash"或者"su",启动的这个新shell就会初始化rc相关 的脚本。这个shell就称为non-login shell。

login shell会执行的脚本有 /etc/profile和~/.bash_profile。
non-login shell会执行的脚本通常有/etc/bashrc (在debian/ubuntu上是/etc/bash.bashrc)和~/.bashrc。

在tty下login进去,得到的是一个login shell。之后使用bash或者su命令得到的是non-login shell。
而在debian/ubuntu下的GNOME用terminal启动出来的shell是non-login shell。退出该non-login shell的话,只需要exit即可。

login shell 读取 /etc/profile 和 ~/.bash_profile , 并且是 先读入 profile 后读入 .bash_profile, 2个文件必读,
至于 bash.bashrc 和 .bashrc 则看 profile 和 .bash_profile 是否明确指定读。

posted on 2012-07-31 09:38 天下 阅读(596) 评论(0)  编辑 收藏 引用 所属分类: Linux使用Linux Shell


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年10月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论