# Quelques commandes

Commandes simples :

\\ : utilisation des apostrophes

Lire les fichiers : <span style="color: rgb(230, 126, 35);">cat, more, less</span>

<span style="color: rgb(230, 126, 35);">nmtui</span> : modifier connexion via interface graphique  
<span style="color: rgb(230, 126, 35);">ctrl + alt + f1 ou f2 </span>: changer de terminal  
<span style="color: rgb(230, 126, 35);">\#</span> : utilisation compte root  
<span style="color: rgb(230, 126, 35);">$</span> : utilisation autre utilisateur  
<span style="color: rgb(230, 126, 35);">~</span> : répertoire de connexion  
<span style="color: rgb(230, 126, 35);">ctrl + s </span>: Pause du terminal  
<span style="color: rgb(230, 126, 35);">ctrl + q </span>: Reprendre le terminal  
<span style="color: rgb(230, 126, 35);">ctrl + w </span>: Effacer le mot  
<span style="color: rgb(230, 126, 35);">ctrl + i </span>: efface l'affichage  
<span style="color: rgb(230, 126, 35);">ctrl + u </span>: efface ligne entière  
<span style="color: rgb(230, 126, 35);">man -k </span>: recherche pages du manuel associés à un mot

<span style="color: rgb(230, 126, 35);">who</span> : liste utilisateurs connectés  
<span style="color: rgb(230, 126, 35);">whoami </span>: affiche utilisateur actuel connecté  
<span style="color: rgb(230, 126, 35);">finger </span>: affiche informations plus précises sur l'utilisateur connecté  
<span style="color: rgb(230, 126, 35);">pwd</span> : affiche répertoire courant  
<span style="color: rgb(230, 126, 35);">Cd ~</span> =&gt; renvoie dans le répertoire /home personnel.

  
<span style="color: rgb(230, 126, 35);">/bin/bash :</span> Shell par défaut | Boîte de l'invite de commande.  
<span style="color: rgb(230, 126, 35);">passwd</span> : modifier mot de passe | commandes liés au mot de passe  
<span style="color: rgb(230, 126, 35);">passwd -l :</span> verrouiller compte  
<span style="color: rgb(230, 126, 35);">passwd -u</span> : déverrouiller compte  
<span style="color: rgb(230, 126, 35);">passwd -d</span> : désactiver saisie du mot de passe pour un compte

<span style="color: rgb(230, 126, 35);">wc </span>: compter le nombre de lignes, mots, caractères contenus dans un fichier.  
<span style="color: rgb(230, 126, 35);">wc -l -w -c </span>(line, word, caracter)

<span style="color: rgb(230, 126, 35);">env</span> : affiche varaibles d'environnement  
<span style="color: rgb(230, 126, 35);">echo</span> : afficher valeur d'environnement  
<span style="color: rgb(230, 126, 35);">date</span> : affiche date  
<span style="color: rgb(230, 126, 35);">exit</span> or <span style="color: rgb(230, 126, 35);">logout </span>: déconnecter utilisateur  
<span style="color: rgb(230, 126, 35);">which \[commande\]</span> : affiche le chemin complet d'une commande

Changement de valeur d'une variable d'environnement  
<span style="color: rgb(230, 126, 35);">export PS1=’\[\\u@\\h \\W \\t\]$’</span>  
Export valide la nouvelle variable.  
<span style="color: rgb(230, 126, 35);">$TMOUT</span> : Variable qui déconnectee automatiquement au bout d'un temps défini.  
La commande export ne marche que pour la session en cours. (temporaire)

==Recherche==  
<span style="color: rgb(230, 126, 35);">\* </span>: substitue le caractères générique ? par n'impoorte quel caractère.  
<span style="color: rgb(230, 126, 35);">\[\] </span>: remplace le caractère par un des caractères donnés. Exemple  
<span style="color: rgb(230, 126, 35);">\[abc\] </span>remplace le caractère par a ou b ou c  
<span style="color: rgb(230, 126, 35);">\[f-z\] :</span> caractère entre f et z. Respect de la casse.  
exemple : <span style="color: rgb(230, 126, 35);">ls \[fr\]?tab</span>  
<span style="color: rgb(230, 126, 35);">! </span>: cherche les caractères ne se trouvant pas entre les  
<span style="color: rgb(230, 126, 35);">{} </span>: Cherche tous les noms de fichiers commençant par une chaîne de caractères au lieu  
d'un seul caractère.  
Avec des doubles apostrophes, les caractères spéciaux sont interprétés mais pas le \* .

<span style="color: rgb(230, 126, 35);">alias </span>: remplace une ligne de commandes complexe par son alias.  
pour l'avoir de manière permanente pour tous les utilisateurs, l'ajouter dans .bashrc  
qui se trouve dans le dossier de connexion de l'utilisateur.

<span style="color: rgb(230, 126, 35);">unalias -a nom\_alias</span> : supprimer alias  
<span style="color: rgb(230, 126, 35);">type</span> : affiche les informations à propos d'une commande et son interprétation.  
<span style="color: rgb(230, 126, 35);">cat </span>: sert à lire un fichier  
<span style="color: rgb(230, 126, 35);">whereis </span>: localiser rapidement une commande externe ainsi que les fichiers  
aide et sources associées.

<span style="color: rgb(230, 126, 35);">source .bash\_profile </span>: recharger le fichier profile sans se déconnecter.  
<span style="color: rgb(230, 126, 35);">set -o </span>: affiche l'état (actif ou inactif) des options  
<span style="color: rgb(230, 126, 35);">set -o \[nom\_option\]</span> : activer  
<span style="color: rgb(230, 126, 35);">set +o \[nom\_option\] </span>: désactiver

Tous les fichiers qui commencent par p ou se terminent par d :  
<span style="color: rgb(230, 126, 35);">ls -d {p\*,\*.d}</span>

==Avancé==  
processus associé à des descripteurs de fichiers.  
point d'entrée = paramètre rentré sur le clavier  
sortie = résultat affiché à l'écran  
Entrée (0) =&gt; Processus =&gt; Sortie (1)  
||  
Erreur (2)

<span style="color: rgb(230, 126, 35);">&lt; </span>: rediriger l'entrée  
<span style="color: rgb(230, 126, 35);">&gt;</span> : rediriger la sortie vers un fichier  
<span style="color: rgb(230, 126, 35);">&gt;&gt;</span> : permet d'ajouter dans un fichier existant  
<span style="color: rgb(230, 126, 35);">2&gt;</span> : redirection de l'erreur standard  
<span style="color: rgb(230, 126, 35);">n&gt;&amp;m</span> : avoir une sortie + erreur dans un seul fichierr  
où n est numéro du descripteur à rediriger et m : numéro de celui vers  
lequel il faut renvoyer les données . exemple : Ou &gt; ficsortie 1&gt;&amp;2

<span style="color: rgb(230, 126, 35);">/dev/null </span>: puit sans fond. Tout ce qui est envoyé est supprimé du système  
exemple : ps -ef &gt; /tmp/test  
<span style="color: rgb(230, 126, 35);">ls bin dev bleu &gt; ficout 2&gt;&gt; ficerr2</span>

<span style="color: rgb(230, 126, 35);">/dev </span>: fichiers qui sont des pointeurs vers des périphériques  
<span style="color: rgb(230, 126, 35);">touch </span>: permet de changer l'heure du fichier et créé un fichier vide.

tubes (pipe) : <span style="color: rgb(230, 126, 35);">|</span>  
<span style="color: rgb(230, 126, 35);">tee </span>: lis l'entrée, génèree le fichier et effectue une copie sur la sortie intermédiaire  
<span style="color: rgb(230, 126, 35);">grep</span> : filtre et garde que ce qui contient après ce paramètre

<span style="color: rgb(230, 126, 35);">su</span> : switch user | changer d'utilisateur  
<span style="color: rgb(230, 126, 35);">su - \[nom\_user\] </span>: tirer permet de garder l'environnement de l'utilisateur actuel  
Lancer une commande en tant qu'utilisateur test :  
<span style="color: rgb(230, 126, 35);">su - test -c "ps -ef"</span>  
chaque commande lancé via su crée une exécution en shell.

<span style="color: rgb(230, 126, 35);">sudo</span> : exécution de commandes en tant que sans élévation de compte /etc/sudoers

  
\[Commandes Avancées\]  
<span style="color: rgb(230, 126, 35);">Dmesg </span>: verbosité du noyau. Les informations sur des périphériques attachés ou détachés apparaissent dedans.  
<span style="color: rgb(230, 126, 35);">Fdisk –l </span>: commandes de table de partition  
<span style="color: rgb(230, 126, 35);">mount</span> : monter le périphérique à un répertoire. | affiche la liste des montages  
<span style="color: rgb(230, 126, 35);">df</span> : fourni la quantité d'espace occupé des systèmes de fichiers.  
<span style="color: rgb(230, 126, 35);">mkfs -t ext4 /dev/sdx</span> : formater au format ext4

editeurs de texte : <span style="color: rgb(230, 126, 35);">vi, nano, emacs</span>  
<span style="color: rgb(230, 126, 35);">cd -</span> =&gt; renvoie dans le répertoire précédent  
<span style="color: rgb(230, 126, 35);">file</span> : permet de déterminer le type d'un fichier  
<span style="color: rgb(230, 126, 35);">stat</span> : indique les informations du bloc où est stocké le fichier  
<span style="color: rgb(230, 126, 35);">mkdir -p</span> : crée arborescence du répertoire

<span style="color: rgb(230, 126, 35);">cp -R</span> : Copier contenu d'un répertoire avec les droits associés.  
<span style="color: rgb(230, 126, 35);">mv</span> : renommer ou déplacer fichiers  
<span style="color: rgb(230, 126, 35);">rename</span> : renommer fichier

<span style="color: rgb(45, 194, 107);">find : rechercher des fichiers</span>  
<span style="color: rgb(45, 194, 107);">exemple : find / -name</span>  
<span style="color: rgb(230, 126, 35);">find -size +1M</span> : fichiers de plus d'un megaoctet  
<span style="color: rgb(230, 126, 35);">find -mtime</span> : heure de modification

<span style="color: rgb(45, 194, 107);">Grep permet de filtrer des lignes.</span>  
<span style="color: rgb(230, 126, 35);">Grep –i </span>=&gt; prend en compte les minuscules et majuscules  
<span style="color: rgb(230, 126, 35);">Grep –l </span>=&gt; affiche uniquement les noms des fichiers possédant des lignes qui correspondent à la valeur donnée.

<span style="color: rgb(230, 126, 35);">Cut </span>=&gt; supprimer une partie de chaque ligne d’un fichier  
<span style="color: rgb(230, 126, 35);">Sort </span>=&gt; trier les lignes d’un fichier.  
<span style="color: rgb(230, 126, 35);">Head</span> =&gt; consulter le début d’un fichier  
<span style="color: rgb(230, 126, 35);">Tail </span>=&gt; consulter la fin d’un fichier.

La commande watch permet d’exécuter un programme périodiquement en affichant le résultat à l’écran

<span style="color: rgb(230, 126, 35);">ln </span>: lien dur (hard link) -&gt; seconde entrée pointant vers le même inode  
<span style="color: rgb(230, 126, 35);">ln -s</span> : lien symbolique -&gt; raccourci