首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

登进shell和非登入shell的区别

2012-11-23 
登入shell和非登入shell的区别使用启动脚本,可以让自定义的环境一劳永逸。这些脚本在shell被创建时运行根据

登入shell和非登入shell的区别

          使用启动脚本,可以让自定义的环境一劳永逸。
          这些脚本在shell被创建时运行
          根据shell是登入shell还是非登入shell,所运行的启动脚本也会不一样
          我们“su - ”是登入shell;“su ”是非登入shell
          放在启动脚本中典型的包括:
          ① 本地变量设置,特别是PS1
             比如,我的:

[oracle@10gR2 ~ $]tail -f .bash_profile | grep -n --color=auto 'PS1'10:export PS1='[\u@10gR2 \W \$]'


          ② 环境变量  例如 PATH  
          ③ 别名
          ④ umask
         
          ㈠ 登入shell
            
             /etc/profile 是登入shell启动后运行的第一个启动脚本
             它只为登入shell运行;非登入shell不会引发这个脚本
             登入shell加载启动脚本的顺序为:
             /etc/profile → /etc/profile.d → .bash_profile → .bashrc → /etc/bashrc
             每个调用的脚本会依次撤销前一个调用脚本中的改变
             在退出登入shell时,我们还可以执行某些任务,如创建自动备份、清除临时文件
             把这些任务放在.bash_logout文件中
            
          ㈡ 非登入shell
         
             非登入shell加载启动脚本的顺序:
             .bashrc → /etc/bashrc → /etc/profile.d

热点排行