Product SiteDocumentation Site

8.6. Shell 环境

命令解译器 (或 shells) 是用户接触电脑的第一个点,必须足够友善。大部分的人使用初始设置的脚本配置其行为 (自动完成、提示字符等)。
bash 是标准的 shell,使用 /etc/bash.bashrc 初始脚本为 “交互” shell 初始化,并以 /etc/profile 作为 “登录” shell。
简单地说,不论本地登录或使用 ssh 远程登录,或以 bash --login 命令登录,都启用登录 shell。在 登录或非登录 shell 里,该 shell 必须是交互的 (例如在 xterm-type 终端机内);或非交互式 (执行脚本时)。
For bash, it is useful to install and activate “automatic completion”. The package bash-completion contains these completions for most common programs and is usually enabled if the user's .bashrc configuration file was copied from /etc/skel/.bashrc. Otherwise it can be enabled via /etc/bash.bashrc (simply uncomment a few lines) or /etc/profile.
In addition to these common scripts, each user can create their own ~/.bashrc and ~/.bash_profile to configure their shell. The most common changes are the addition of aliases; these are words that are automatically replaced with the execution of a command, which makes it faster to invoke that command. For instance, you could create the la alias for the command ls -la | less command; then you only have to type la to inspect the contents of a directory in detail. Please note that the shell needs to be reinitialized after adding an alias, e.g. by starting a new shell.
Setting default environment variables is an important element of shell configuration. Leaving aside the variables specific to a shell, it is preferable to place system wide variables in the /etc/environment file, since it is used by the various programs likely to initiate a shell session. Variables typically defined there include ORGANIZATION, which usually contains the name of the company or organization, and HTTP_PROXY, which indicates the existence and location of an HTTP proxy. Other options include to set system wide variables via scripts in /etc/profile.d, or session wide variables via .pam_environment or .profile, where the latter can override any definition contained in the first. The file /etc/default/locale is meant to contain system wide locale related environment variables.