[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Ceci est une ancienne révision du document !


BASH ou le Bourne Again Shell

Qu'est ce Qu'un Shell?

Ouais, c'est quoi donc le Shell? Et bien, le Shell est fondamentalement un environnement utilisateur de lignes de commande. En substance, il s'agit d'une application qui s'exécute lorsque l'utilisateur se connecte et lui permet d'exécuter des applications supplémentaires. À certains égards, le Shell est très similaire à une interface utilisateur graphique, en ce sens qu'il fournit un cadre pour l'exécution des commandes et lancer des programmes. Il existe une panoplie de Shell incluse avec une installation complète de Slackware. Toutefois dans ce livre, nous allons seulement discuter de bash (1), le Bourne Again Shell. Les utilisateurs avancés peuvent envisager d'utiliser le puissant zsh (1), et les utilisateurs familiers avec les systèmes UNIX plus anciens peuvent apprécier ksh. Le masochiste pourrait vraiment choisir le csh, mais les nouveaux utilisateurs devraient s'en tenir à bash.

Variables d'Environnement

All shells make certain tasks easier for the user by keeping track of things in environment variables. An environment variable is simply a shorter name for some bit of information that the user wishes to store and make use of later. For example, the environment variable PS1 tells bash how to format its prompt. Other variables may tell applications how to run. For example, the LESSOPEN variable tells less to run that handy lesspipe.sh preprocessor we talked about, and LS_OPTIONS tuns on color for ls.

Setting your own envirtonment variables is easy. bash includes two built-in functions for handling this: set and export. Additionally, an environment variable can be removed by using unset. (Don't panic if you accidently unset an environment variable and don't know what it would do. You can reset all the default variables by logging out of your terminal and logging back in.) You can reference a variable by placing a dollar sign ($) in front of it.

darkstar:~$ set FOO=bar
darkstar:~$ echo $FOO
bar

The primary difference between set and export is that export will (naturally) export the variable to any sub-shells. (A sub-shell is simply another shell running inside a parent shell.) You can easily see this behavior when working with the PS1 variable that controls the bash prompt.

darkstar:~$ set PS1='FOO '
darkstar:~$ export PS1='FOO '
FOO 

There are many important environment variables that bash and other shells use, but one of the most important ones you will run across is PATH. PATH is simply a list of directories to search through for applications. For example, top(1) is located at /usr/bin/top. You could run it simply by specifying the complete path to it, but if /usr/bin is in your PATH variable, bash will check there if you don't specify a complete path one your own. You will most likely first notice this when you attempt to run a program that is not in your PATH as a normal user, for instance, ifconfig(8).

darkstar:~$ ifconfig
bash: ifconfig: command not found
darkstar:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:.

Above, you see a typical PATH for a mortal user. You can change it on your own the same as any other environment variable. If you login as root however, you'll see that root has a different PATH.

darkstar:~$ su -
Password: 
darkstar:~# echo $PATH
/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin

Les Caractères Génériques

La Touche de Tabulation

Redirection d'Entrée et de Sortie

Gestion de Taches

Les Terminaux

Personalisation

Navigation

Chapitre précédent : L'invite de commandes (shell)

Chapitre suivant : Contrôle des processus

Sources

  • Publié iniialement par Alan Hicks, Chris Lumens, David Cantrell, Logan Johnson
  • Traduction Initiale de escaflown

 fr:slackbook:bash ()