Product SiteDocumentation Site

8.6. Entorn d'intèrpret d'ordres

Els intèrprets d'ordres (o «shells» en anglès) poden ser el primer punt de contacte d'un usuari amb l'ordinador, i per tant han de ser bastant “amigables”. La majoria utilitzen scripts d'inicialització que permeten la configuració del seu comportament (compleció automàtica, text indicatiu, etc.).
bash, la «shell» estàndard, utilitza l'«script» d'inicialització /etc/bash.bashrc per a les «shells» “interactives” i /etc/profile per a les «shells» “d'inici de sessió”.
En termes senzills, s'invoca un intèrpret d'ordres d'inici de sessió quan inicieu la sessió a la consola tant localment com remota a través d'ssh, o quan executeu una ordre explícita de bash --login. Independentment de si és un intèrpret d'ordres d'inici de sessió o no, una «shell» pot ser interactiva (en un terminal de tipus xterm, per exemple); o no interactiva (quan executa un «script»).
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.