各种外壳轮廓有什么区别?

0x4*_*672 8 bash shell profile

〜/ .bashrc,〜/ .bash_login,〜/ .bash_logout,〜/ .bash_profile,〜/ .profile,/ etc/profile,/ etc/bash.bashrc,/ etc/ssh/ssh_config和sshd_config之间有什么区别,什么时候装,他们的目的是什么?

0x4*_*672 6

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
Run Code Online (Sandbox Code Playgroud)

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

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

系统范围的默认值为..

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

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

  • ~/.profile ..login shell,登录后调用
  • ~/.bashrc ..non-login shell,如果已经登录的话
  • ~/.bash_profile ..login shell,登录后调用(优先级较低)

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

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

以下链接很有用:.bashrc vs .bashprofile.bash_profile vs .bashrc,bash手册页(man bash)和Zsh/Bash启动文件加载顺序(.bashrc,.zshrc等).