交互式Shell和非交互式Shellshell
登陆式Shell和非登陆式Shellbash
使用启动脚本,可让自定义的环境一劳永逸。spa
这些脚本在shell被建立时运行根据shell是登陆shell仍是非登陆shell,所运行的启动脚本也会不同。code
su - username是登陆shell;su username是非登陆shell(注意su - username中间有空格)。直接打开终端是非登陆shell。blog
keegen@keegensCP:~$ su - keegen 密码: keegen@keegensCP:~$ echo $0 -su keegen@keegensCP:~$ logout keegen@keegensCP:~$ echo $0 bash
/etc/profile 是登入shell启动后运行的第一个启动脚本,它只为登入shell运行;非登入shell不会引起这个脚本。ip
登入shell加载启动脚本的顺序为:
terminal
/etc/profile → /etc/profile.d → ~/.bash_profile → ~/.bashrc → /etc/bashrc
每一个调用的脚本会依次撤销前一个调用脚本中的改变。it
在退出登入shell时,咱们还能够执行某些任务,如建立自动备份、清除临时文件。把这些任务放在.bash_logout文件中。class
非登入shell加载启动脚本的顺序:
登录
~/.bashrc → /etc/bashrc → /etc/profile.d