Chapitre 3 : Commandes GNU et Unix Flashcards

(31 cards)

1
Q

Quelle commande affiche le contenu d’un fichier texte ?

A

cat fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Comment rechercher un motif dans un fichier ?

A

grep motif fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Comment extraire la première colonne d’un fichier CSV délimité par ‘:’ ?

A

cut -d':' -f1 fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Comment compter le nombre de lignes d’un fichier ?

A

wc -l fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Comment trier un fichier par ordre alphabétique ?

A

sort fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Comment afficher les 10 premières lignes d’un fichier ?

A

head -n 10 fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Comment afficher les 10 dernières lignes d’un fichier ?

A

tail -n 10 fichier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Quelle est la différence entre > et >> ?

A

> écrase un fichier, >> ajoute à la fin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Comment rediriger les erreurs vers un fichier ?

A

commande 2> erreurs.log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Comment utiliser un fichier comme entrée pour une commande ?

A

commande < fichier.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Comment rediriger stdout et stderr vers le même fichier ?

A

commande > fichier.log 2>&1 ou &> en Bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Quelle commande affiche tous les processus en cours ?

A

ps aux ou ps -ef

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Comment tuer un processus proprement ?

A

kill -15 PID (SIGTERM)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Comment forcer l’arrêt d’un processus ?

A

kill -9 PID (SIGKILL)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Quelle commande affiche l’historique des commandes ?

A

history

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Comment répéter la dernière commande ?

17
Q

Comment remplacer un motif dans un fichier ?

A

sed 's/ancien/nouveau/g' fichier

18
Q

Comment afficher les lignes uniques d’un fichier ?

A

sort fichier | uniq

19
Q

Quelle commande affiche l’heure système ?

20
Q

Comment afficher le manuel d’une commande ?

21
Q

Comment trouver l’emplacement d’une commande ?

A

which commande ou whereis commande

22
Q

Comment afficher le type d’une commande ?

A

type commande

23
Q

Quelle commande affiche l’utilisation du disque ?

24
Q

Comment calculer la taille d’un répertoire ?

A

du -sh /chemin

25
Quelle commande permet de comparer deux fichiers ?
`diff fichier1 fichier2` ou `vimdiff`
26
Comment compresser un fichier avec gzip ?
`gzip fichier` (crée fichier.gz)
27
Comment décompresser un fichier .gz ?
`gunzip fichier.gz`
28
Comment suivre les nouvelles lignes d'un fichier en temps réel ?
`tail -f fichier.log`
29
Comment convertir des tabulations en espaces ?
`expand fichier`
30
Comment inverser l'ordre des lignes d'un fichier ?
`tac fichier` (contraire de `cat`)
31
Comment supprimer les lignes vides d'un fichier ?
`grep -v '^$' fichier`