Avec le système d'exploitation Linux, vous avez plus de raisons d'apprendre et d'utiliser la ligne de commande qu'avec Windows, plus particulièrement parce que Microsoft a relégué la plupart de ces fonctions dans son interface graphique. Pour certaines tâches, il est bien plus efficace d'utiliser la ligne de commande, et pour les puristes et experts de Linux, c'est bien souvent la seule méthode de faire. Dans tous les cas, il est tout à votre avantage de vous familiariser à la ligne de commande.
Cette page vous donne un aperçu des commandes de base. Pour des informations plus complètes, vous pouvez vous rendre sur http://linuxcommand.org/
Un shell est un interpréteur de commandes : il prend les commandes et les exécutes. Pour ce faire, il implémente un langage de programation. Comme vous pouvez le deviner, la ligne de commande. A shell is a command-line interpreter: it takes commands and executes them. To do that, it implements a programming language. As you can probably guess, the CLI can be a powerful tool. You can write your own programs, called shell scripts, that can do a variety of things. However, we will focus on basic commands in this guide.
Bash (Bourne-again shell) is the default shell for most current Linux distributions (and Mac OS X) and can be run on most Unix-like operating systems. We make the assumption that you are running Bash, though some commands will work in other shells. To check what shell you are currently using, open the console, type echo $SHELL, and press Enter. It should return a pathname ending with /bash.
In a shell <tab> is your friend. When using the CLI pressing tab once or twice produces very desirable results. One press will complete your command if there is only one possible filename matching what you're typing; pressing twice produces a list of possible filenames.
Most commands can be modified with arguments, which are specified after the command, that change the behavior of the basic command. Arguments can be fundamental to the command (e.g., a file is the argument to a delete command) or optional. In the latter case, arguments are preceded by a dash (-) in Linux or a forward slash (/) in DOS/Windows.
To see what arguments are available for a certain command, you can search the internet or, conveniently, read the man pages (short for “manual pages”) for that command. Man pages are self-contained documents that can help you more fully utilize the potential of the command line. Simply type man before the command name (the argument), and press Enter. Press q to leave a man page and return to the terminal.
Some commands require administrative access. If you are not already logged in as the root user, you must run these commands with the root user's privileges. You can do this either by typing sudo at the beginning of the command or, alternatively, by running the su command before executing any such command. In the case of sudo, you will be asked for your (user) password. su, on the other hand, requires the use of the root password. (Note: The characters you type do not appear on screen. This is normal.)
Using the command sudo bash or sudo su, you can use bash as root, which can be useful when performing a series of administrative tasks. However, once you have finished, you should revert to your user account, using the command exit (or the shortcut Ctrl-D).
| Commande bash | Commande DOS | Fonction |
|---|---|---|
| cat | type | Affiche un fichier texte |
cd dir | cd/chdir dir | Change le répertoire courant pour dir |
| pwd | cd (by itself) | Affiche le répertoire courant |
| chmod | attrib | Modifie les droits sur le fichier |
| clear | cls | Vide le terminal |
| cp | copy | Copie le fichier |
| date | date, time | Afficher/Changer la date et l'heure |
| diff | fc | Compare deux fichiers |
| df | Affiche l'espace disque disponible | |
| echo | echo | Affiche unmesage sur l'écran |
| exit | exit | Sort du shell |
| free | mem | Affiche l'utilisation de la mémoire |
| fsck | chkdsk, scandisk | Teste le système de fichier |
| grep | find | recherche de fichiers contenant la chaîne en argument |
| history | ?? | Affiche l'historique de vos commandes |
| less | more | Affiche par écrans successifs un fichier long |
| ls | dir | Affiche le contenu d'un répertoire |
| ls -l | l'option -l permet un affichage plus lisible | |
find -name filename | dir /s filename | Cherche le fichier filename |
| mkdir | md/mkdir | Crée un répertoire |
| mv | move, ren/rename | Déplace ou renome fichiers et/ou répertoires |
| rm | del, deltree | Supprime un fichier |
| rmdir | rd/rmdir | Supprime un répertoire |
| sort | sort | range par ordre des fichiers |
| uname | ver | Affiche les informations système |
| nano | edit | Editeur de texte basique |
| kwrite | Lance un éditeur de texte en mode graphique | |
| XandrosFileManager | Lance le gestionnaire fichiers de Xandros | |
| ip addr | Affiche votre adresse IP | |
| sudo ifconfig | grep "inet addr" | Affiche votre adresse IP |