各种外壳轮廓之间有什么区别? [英] What is the difference between the various shell profiles?

查看:164
本文介绍了各种外壳轮廓之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

〜/.bashrc,〜/.bash_login,〜/.bash_logout,〜/.bash_profile,〜/.profile,/etc/profile,/etc/bash.bashrc,/etc/ssh/ssh_config之间有什么区别和sshd_config,它们何时加载以及它们的用途是什么?

What's the difference between ~/.bashrc, ~/.bash_login, ~/.bash_logout, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, /etc/ssh/ssh_config and sshd_config, when are they loaded and what are their purposes?

推荐答案

bash的手册页上显示了bash shell的以下初始化文件:

The man page for bash says there are the following initialization files for bash shells:

/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版本一样多:csh,ksh,bash,zsh,... Bash有.bashrc,Zsh有.zshrc等.人们还可以区分登录shell和非登录shell. -login shell,以及在系统范围的默认值和用户特定的默认值之间.

Apparently there seem to be different configuration files for the different shells (bash, zsh, csh, and others). There seem to be as many shells as different linux and unix versions: csh, ksh, bash, zsh, ... Bash has a .bashrc, Zsh has a .zshrc, etc. One can also distinguish between login shells and non-login shells and between system-wide defaults and user-specific defaults.

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

It makes sense to distinguish between login and non-login shells, because some commands should be processed only at login, while other commands should run everytime you open a new terminal window. That is the difference between .bash_profile and .bashrc. For bash the .bashrc is reloaded every time you start a new copy of bash, i.e. when you start a new bash but do not login. The .bash_profile or .profile is loaded only when you login. The abbtreviation rc in bashrc stands for "run commands" or "run control" and is a convention adopted from older Unix systems.

系统范围的默认值.

  • /etc/profile ..login shell,用于具有登录名的交互式shell
  • /etc/bashrc ..non-login Bash shell
  • /etc/profile ..login shells, for interactive shells with login
  • /etc/bashrc ..non-login Bash shells

主目录〜for中用户特定的默认设置.

user-specific defaults in home directory ~ for..

  • ~/.profile ..login外壳,登录后调用
  • ~/.bashrc ..非登录外壳程序(如果已登录)
  • ~/.bash_profile ..login外壳,登录后调用(优先级较低)
  • ~/.profile ..login shells, called after login
  • ~/.bashrc ..non-login shells, if already logged in
  • ~/.bash_profile ..login shells, called after login (lower priority)

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

user-specific defaults in home directory for login and logout

  • ~/.bash_login ..login外壳程序(登录时调用)
  • ~/.bash_logout ..login外壳程序(注销时调用)
  • ~/.bash_login ..login shells (called upon login)
  • ~/.bash_logout ..login shells (called upon logout)

以下链接很有帮助: .bashrc与.bashprofile .bash_profile与.bashrc

The following links were helpful: .bashrc vs .bashprofile and .bash_profile vs .bashrc, the bash manual page (man bash), and Zsh/Bash startup files loading order (.bashrc, .zshrc etc.).

这篇关于各种外壳轮廓之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆