加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 各种shell配置文件有什么区别?

发布时间:2020-12-16 01:13:40 所属栏目:安全 来源:网络整理
导读:?/ .bashrc,?/ .bash_login,?/ .bash_logout,?/ .bash_profile,?/ .profile,/ etc / profile,/ etc / bash.bashrc,/ etc / ssh / ssh_config和sshd_config之间有什么区别,什么时候装,他们的目的是什么? bash的手册页说bash shell有以下初始化文件: /etc/pr
?/ .bashrc,?/ .bash_login,?/ .bash_logout,?/ .bash_profile,?/ .profile,/ etc / profile,/ etc / bash.bashrc,/ etc / ssh / ssh_config和sshd_config之间有什么区别,什么时候装,他们的目的是什么?
bash的手册页说bash shell有以下初始化文件:
/etc/profile
      The systemwide initialization file,executed for login shells
/etc/bash.bashrc
      The systemwide per-interactive-shell startup file
/etc/bash.bash.logout
      The systemwide login shell cleanup file,executed when a login shell exits
~/.bash_profile
      The personal initialization file,executed for login shells
~/.bashrc
      The individual per-interactive-shell startup file
~/.bash_logout
      The individual login shell cleanup file,executed when a login shell exits
~/.inputrc
      Individual readline initialization file

显然,不同的shell(bash,zsh,csh和其他)似乎有不同的配置文件.似乎有不同的linux和unix版本的shell:csh,ksh,bash,… Bash有一个.bashrc,Zsh有.zshrc等.还可以区分登录shell和非登录shell以及系统范围的默认值和用户特定的默认值之间.

区分登录和非登录shell是有意义的,因为某些命令只应在登录时处理,而其他命令应在每次打开新的终端窗口时运行.这就是.bash_profile and .bashrc之间的区别.对于bash,每次启动bash的新副本时都会重新加载.bashrc,即当你启动一个新的bash但是没有登录时.只有在您登录时才会加载.bash_profile或.profile. bashrc中的abbtreviation rc代表“运行命令”或“运行控制”,是旧Unix系统采用的约定.

系统范围的默认值为..

> / etc / profile ..login shell,用于登录的交互式shell
> / etc / bashrc ..non-login Bash shell

主目录中用户特定的默认值?为..

>?/ .profile ..login shell,登录后调用
>?/ .bashrc ..非登录shell,如果已经登录
>?/ .bash_profile ..login shell,登录后调用(优先级较低)

用于登录和注销的主目录中的特定于用户的默认值

>?/ .bash_login ..login shell(登录时调用)
>?/ .bash_logout ..login shell(在注销时调用)

以下链接很有用:.bashrc vs .bashprofile和.bash_profile vs .bashrc,bash manual page(man bash)和Zsh/Bash startup files loading order (.bashrc,.zshrc etc.).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读