Version : 2022.01

Dernière mise-à-jour : 2022/11/01 07:28

Topic 206: System Maintenance

Contenu du Module

  • Topic 206: System Maintenance
    • Contenu du Module
    • Types de Sauvegardes
      • Sauvegarde complète
      • Sauvegarde différentielle
      • Sauvegarde incrémentale
      • Sauvegarde décrémentale
    • Outils Classiques de Sauvegarde
      • Préparation
      • LAB #1 - La Commande tar
        • 1.1 - Présentation
        • 1.2 - Travailler avec la Commande tar
        • 1.2 - La Commande GPL tar et la Compression
      • LAB #2 - La Commande cpio
        • 2.1 - Présentation
        • 2.2 - Travailler avec la Commande cpio
      • LAB #3 - La Commande dd
        • 3.1 - Présentation
        • 3.2 - Travailler avec la Commande dd
      • Les Commandes dump et restore
        • Présentation
    • Outils Avancés de Sauvegarde
      • Outils de Sauvegarde Unidirectionnelle
      • Outils de Sauvegarde Multidirectionnelle
      • Outils de Sauvegarde des Partitions
      • LAB #4 - Que Sauvegarder en Priorité ?
        • 4.1 - Sauvegarde de la Liste des Paquets
        • 4.2 - Sauvegarde d'un Mémo sur la Structure du Disque Dur Système
        • 4.3 - Sauvegarde d'un Mémo sur les Points de Montage du Disque Dur Système
        • 4.4 - Sauvegarde du Chargeur de Démarrage
          • GRUB Legacy
          • GRUB 2 avec BIOS
          • GRUB 2 avec EFI
        • 4.5 - Sauvegarde des Dossiers Utilisateurs
      • LAB #5 - Rsync
        • 5.1 - Présentation
        • 5.2 - Travailler avec la Commande rsync
    • LAB #6 - Commandes Diverses
      • 6.1- La Commande wall
      • 6.2 - La Commande patch
    • LAB #7 - Compiler à partir des sources
      • 7.1 - ./configure
      • 7.2 - make
      • 7.3 - make check
      • 7.4 - make install
    • Fichiers Divers
      • /etc/motd
      • /etc/issue

Types de Sauvegardes

Sauvegarde complète

Dans ce cas on sauvegarde tous les fichiers et dossiers, toute la partition ou tout le disque :

La restauration nécessite :

  • La dernière sauvegarde complète.

Avantage :

  • Restauration plus rapide et plus simple que les restaurations à partir de sauvegardes différentielles et incrémentales.

Inconvénient :

  • Nécessite plus d'espace de stockage que les sauvegardes différentielles et incrémentales.

Sauvegarde différentielle

Dans ce cas on sauvegarde des données modifiées ou nouvellement ajoutées sur la base de la dernière sauvegarde complète :

La restauration nécessite :

  • La dernière sauvegarde complète,
  • La dernière sauvegarde différentielle.

Avantage :

  • Restauration plus rapide que la restauration à partir d'une sauvegarde incrémentale.

Inconvénient :

  • Nécessite plus d'espace de stockage que la sauvegarde incrémentale.

Sauvegarde incrémentale

Dans ce cas, on ne sauvegarde que ce qui a changé depuis la dernière sauvegarde quelle qu'elle soit (complète, différentielle ou incrémentale) :

La restauration nécessite :

  • La dernière sauvegarde complète,
  • Toutes les sauvegardes incrémentales effectuées depuis, et dans l'ordre.

Avantage :

  • Sauvegarde plus rapide que la sauvegarde complète ou différentielle,
  • Nécessite moins d'espace de stockage que la sauvegarde différentielle.

Inconvénient :

  • Plus longue à restaurer.

Sauvegarde décrémentale

Dans ce cas on sauvegarde tous les fichiers puis on produit une sauvegarde de ce qui a changé depuis la dernière sauvegarde complète. Cette sauvegarde est appelée une sauvegarde décrémentale :

La restauration nécessite :

  • La dernière sauvegarde complète.

La restauration de J-1 nécessite :

  • La dernière sauvegarde complète,
  • La sauvegarde décrémentale J.

Par exemple pour obtenir un état du système J1 quand on est à J2, il convient de restaurer la sauvegarde complète de J2 qui est en réalité J2+J1 puis la sauvegarde décrémentale -J2. De cette façon et d'une manière mathématique on obtient : J2 + J1 -J2 = J1.

Avantage :

  • Restauration plus rapide et plus simple que les restaurations à partir de sauvegardes différentielles et incrémentales.

Inconvénient :

  • Nécessite plus de manipulation de données à chaque sauvegarde.

Outils classiques de sauvegarde

Préparation

Afin de poursuivre, il convient de créer une arborescence à sauvegarder :

root@debian11:~# mkdir -p /test/repY; mkdir /test/repZ
root@debian11:~# cd /test/repY; touch Y1 Y2 Y3
root@debian11:/test/repY# cd /test/repZ; touch Z1 Z2
root@debian11:/test/repZ# ls -lR /test
/test:
total 8
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repY
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repZ

/test/repY:
total 0
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y1
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y2
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y3

/test/repZ:
total 0
-rw-r--r-- 1 root root 0 Apr 28 10:32 Z1
-rw-r--r-- 1 root root 0 Apr 28 10:32 Z2

LAB #1 - La Commande tar

1.1 - Présentation

Le programme tar a été originellement prévu pour sauvegarder sur des bandes magnétiques, d'où son nom issu de tape archiver.

La commande tar peut sauvegarder vers :

  • un fichier spécial, par exemple le nom d'un lecteur de bande,
  • un fichier ordinaire sur disque,
  • la sortie standard pour être utilisé dans un pipe.

1.2 - Travailler avec la Commande tar

Vous allez maintenant sauvegarder votre dossier test ainsi que son contenu vers un fichier :

root@debian11:/test/repZ# tar cvf /tmp/test.tar /test
tar: Removing leading `/' from member names
/test/
/test/repZ/
/test/repZ/Z2
/test/repZ/Z1
/test/repY/
/test/repY/Y2
/test/repY/Y3
/test/repY/Y1

Pour visualiser la table of contents de votre sauvegarde, utilisez la commande suivante :

root@debian11:/test/repZ# tar tvf /tmp/test.tar
drwxr-xr-x root/root         0 2022-04-28 10:32 test/
drwxr-xr-x root/root         0 2022-04-28 10:32 test/repZ/
-rw-r--r-- root/root         0 2022-04-28 10:32 test/repZ/Z2
-rw-r--r-- root/root         0 2022-04-28 10:32 test/repZ/Z1
drwxr-xr-x root/root         0 2022-04-28 10:32 test/repY/
-rw-r--r-- root/root         0 2022-04-28 10:32 test/repY/Y2
-rw-r--r-- root/root         0 2022-04-28 10:32 test/repY/Y3
-rw-r--r-- root/root         0 2022-04-28 10:32 test/repY/Y1

Afin de créer une sauvegarde incrémentale, vous avez besoin de créer un fichier qui servira de référence de date :

root@debian11:/test/repZ# touch /tmp/dateref

Modifiez maintenant deux des fichiers de votre arborescence test :

root@debian11:/test/repZ# echo "Debian est super \!" > /test/repY/Y1
root@debian11:/test/repZ# echo "Debian 11 is wonderful \!" > /test/repZ/Z1

Pour procéder à votre sauvegarde incrémentale, vous devez sauvegarder uniquement les fichiers modifiés ou créés depuis la création de votre fichier /tmp/dateref.

Saisissez donc la commande suivante :

root@debian11:/test/repZ# tar -cvf /tmp/incremental.tar -N /tmp/dateref /test
tar: Removing leading `/' from member names
/test/
/test/repZ/
tar: /test/repZ/Z2: file is unchanged; not dumped
/test/repZ/Z1
/test/repY/
tar: /test/repY/Y2: file is unchanged; not dumped
tar: /test/repY/Y3: file is unchanged; not dumped
/test/repY/Y1

Important - Notez l'utilisation de l'option -N avec l’argument /tmp/dateref qui permet d'identifier les fichiers modifiés ou créés depuis la création de /tmp/dateref.

Contrôlez maintenant le contenu de l'archive /tmp/incremental.tar :

root@debian11:/test/repZ# tar tvf /tmp/incremental.tar
drwxr-xr-x root/root         0 2022-04-28 10:32 test/
drwxr-xr-x root/root         0 2022-04-28 10:32 test/repZ/
-rw-r--r-- root/root        26 2022-04-28 10:35 test/repZ/Z1
drwxr-xr-x root/root         0 2022-04-28 10:32 test/repY/
-rw-r--r-- root/root        20 2022-04-28 10:35 test/repY/Y1

Supprimez maintenant le contenu du répertoire test :

root@debian11:/test/repZ# rm -rf /test/*

Important - Notez que le système vous permet de supprimer le répertoire /test/repZ, or vous vous situez dans ce même répertoire !

Afin de pouvoir restaurer les fichiers de votre première sauvegarde, placez-vous à la racine de votre système et restaurez le contenu de votre répertoire test en saisissant la commande tar suivante :

root@debian11:/test/repZ# cd /
root@debian11:/# tar xvf /tmp/test.tar
test/
test/repZ/
test/repZ/Z2
test/repZ/Z1
test/repY/
test/repY/Y2
test/repY/Y3
test/repY/Y1

Constatez maintenant que l'opération s'est bien déroulée :

root@debian11:/# ls -lR /test
/test:
total 8
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repY
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repZ

/test/repY:
total 0
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y1
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y2
-rw-r--r-- 1 root root 0 Apr 28 10:32 Y3

/test/repZ:
total 0
-rw-r--r-- 1 root root 0 Apr 28 10:32 Z1
-rw-r--r-- 1 root root 0 Apr 28 10:32 Z2

Important - Notez qu'à ce stade les fichiers /test/repY/Y1 et /test/repZ/Z1 sont vides.

Restaurez maintenant votre archive incrémentale :

root@debian11:/# tar xvf /tmp/incremental.tar
test/
test/repZ/
test/repZ/Z1
test/repY/
test/repY/Y1

Constatez maintenant que l'opération s'est bien déroulée :

root@debian11:/# ls -lR /test
/test:
total 8
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repY
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repZ

/test/repY:
total 4
-rw-r--r-- 1 root root 20 Apr 28 10:35 Y1
-rw-r--r-- 1 root root  0 Apr 28 10:32 Y2
-rw-r--r-- 1 root root  0 Apr 28 10:32 Y3

/test/repZ:
total 4
-rw-r--r-- 1 root root 26 Apr 28 10:35 Z1
-rw-r--r-- 1 root root  0 Apr 28 10:32 Z2

Important - Notez que les fichiers /test/repY/Y1 et /test/repZ/Z1 sont maintenant non-vides.

1.3 - La Commande GPL tar et la Compression

Dernièrement, la commande tar peut archiver en utilisant des algorithmes de compression :

Algorythme Option de la commande tar
gzip z
bzip2 j
lzma J

LAB #2 - La Commande cpio

2.1 - Présentation

La commande cpio (Copy Input To Output). cpio peut gérer les archives au format tar. La différence majeure entre tar et cpio est que ce dernier stocke les chemins d'accès aux fichiers sauvgardés en même temps que les fichiers eux-mêmes. Ceci implique que dans le cas où le chemin absolu a été spécifié lors de la sauvegarde, il est impossible de restaurer un fichier à un autre emplacement que son emplacement d'origine.

Vous allez utiliser maintenant le logiciel cpio pour effectuer les sauvegardes et restaurations.

2.2 - Travailler avec la Commande cpio

Dans un premier temps, vous devez utiliser la commande find pour construire une liste de fichiers à sauvegarder :

root@debian11:/# find /test > /tmp/cpio.list
root@debian11:/# cat /tmp/cpio.list
/test
/test/repZ
/test/repZ/Z2
/test/repZ/Z1
/test/repY
/test/repY/Y2
/test/repY/Y3
/test/repY/Y1

Sauvegardez maintenant les fichiers et répertoires référencés par le fichier /tmp/cpio.list :

root@debian11:/# cpio -ov < /tmp/cpio.list > /tmp/test.cpio
/test
/test/repZ
/test/repZ/Z2
/test/repZ/Z1
/test/repY
/test/repY/Y2
/test/repY/Y3
/test/repY/Y1
1 block

Consultez maintenant la table of contents de votre sauvegarde :

root@debian11:/# cpio -it < /tmp/test.cpio
/test
/test/repZ
/test/repZ/Z2
/test/repZ/Z1
/test/repY
/test/repY/Y2
/test/repY/Y3
/test/repY/Y1
1 block

Supprimez maintenant le répertoire /test/repY et son contenu :

root@debian11:/# rm -rf /test/repY

Contrôlez le bon déroulement de la suppression :

root@debian11:/# ls -lR /test
/test:
total 4
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repZ

/test/repZ:
total 4
-rw-r--r-- 1 root root 26 Apr 28 10:35 Z1
-rw-r--r-- 1 root root  0 Apr 28 10:32 Z2

Restaurez les fichiers supprimés :

root@debian11:/# cpio -ivdum "/test/repY/*" < /tmp/test.cpio
/test/repY/Y2
/test/repY/Y3
/test/repY/Y1
1 block

Important - Notez l'utilisation de la chaîne “/test/repY/*” qui permet de rechercher uniquement le répertoire repY ainsi que les fichiers Y1, Y2 et Y3 dans l'archive test.cpio.

Contrôlez le bon déroulement de la restauration :

root@debian11:/# ls -lR /test
/test:
total 8
drwxr-xr-x 2 root root 4096 Apr 28 10:43 repY
drwxr-xr-x 2 root root 4096 Apr 28 10:32 repZ

/test/repY:
total 4
-rw-r--r-- 1 root root 20 Apr 28 10:35 Y1
-rw-r--r-- 1 root root  0 Apr 28 10:32 Y2
-rw-r--r-- 1 root root  0 Apr 28 10:32 Y3

/test/repZ:
total 4
-rw-r--r-- 1 root root 26 Apr 28 10:35 Z1
-rw-r--r-- 1 root root  0 Apr 28 10:32 Z2

LAB #3 - La Commande dd

3.1 - Présentation

La commande dd n'est pas réellement une commande de sauvegarde.

La commande dd copie le fichier passé en entrée dans le fichier de sortie en limitant le nombre d'octets copiés par l'utilisation de deux options :

  • count
    • le nombre
  • bs
    • la taille du bloc à copier

3.2 - Travailler avec la Commande dd

Vous allez utiliser maintenant le logiciel dd pour effectuer une sauvegarde de votre boot.img.

Effectuez une sauvegarde des premiers 512 octets de votre disque /dev/sda :

root@debian11:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda           8:0    0   32G  0 disk  
├─sda1        8:1    0   31G  0 part  /
├─sda2        8:2    0    1K  0 part  
└─sda5        8:5    0  975M  0 part  [SWAP]
sdb           8:16   0   64G  0 disk  
sdc           8:32   0    4G  0 disk  
├─sdc1        8:33   0  100M  0 part  
├─sdc2        8:34   0  100M  0 part  
├─sdc3        8:35   0  100M  0 part  
├─sdc4        8:36   0    1K  0 part  
├─sdc5        8:37   0  500M  0 part  
├─sdc6        8:38   0  200M  0 part  
│ └─vg0-lv1 254:0    0  104M  0 lvm   
├─sdc7        8:39   0  300M  0 part  
│ └─vg0-lv2 254:1    0  112M  0 lvm   
├─sdc8        8:40   0  500M  0 part  
│ └─md1       9:1    0  996M  0 raid5 
├─sdc9        8:41   0  400M  0 part  
│ └─vg0-lv2 254:1    0  112M  0 lvm   
├─sdc10       8:42   0  500M  0 part  
│ └─md1       9:1    0  996M  0 raid5 
├─sdc11       8:43   0  500M  0 part  
│ └─md1       9:1    0  996M  0 raid5 
└─sdc12       8:44   0  200M  0 part  
sr0          11:0    1  378M  0 rom 

root@debian11:/# dd if=/dev/sda of=/tmp/boot.save bs=1 count=512
512+0 records in
512+0 records out
512 bytes copied, 0.00214801 s, 238 kB/s

Les Commandes dump et restore

Présentation

Les commandes dump et restore se basent sur le format d'enregistrement des données ( ext3 ). Pour cette raison il n'est pas possible de sauvegarder des répertoires à l'intérieur d'un système de fichiers mais uniquement des systèmes de fichiers complets.

Il est important de noter que le système de fichier ne doit pas être utilisé pendant le processus de dump. Pour cette raison il est normalement conseillé de démonter le système de fichiers.

Il existe 10 niveaux de dump possibles de 0 à 9. Lors d'un dump le niveau est spécifié. Chaque fois qu'un dump est effectué, cette information est sauvegardée dans le fichier /etc/dumpdates.

Par définition un dump de niveau 0 est une sauvegarde complète tandis que le dump de niveau 1 est une sauvegarde incrémentale.

Notez que les fichiers sont sauvegardés avec des nom relatifs. Ceci implique que vous devez vous positionner dans le système de fichiers lors de la restauration avec la commande restore.

Outils Avancés de Sauvegarde

Outils de Sauvegarde Unidirectionnelle

Ces outils sauvegardent des fichiers vers un répertoire local ou distant dans un seul sens.

Ce premier tableau compare les outils par rapport aux caractéristiques et aux capacités des opérations de sauvegarde :

Outil Backend Sauvegarde différentielle Sauvegarde incrémentale Sauvegarde décrémentale Planification incorporée Restauration incorporée Chiffrement Compression Site
AMANDA tar, gzip AMANDA
Areca Backup Aucun   Areca Backup
bacula (Bareos) MySQL bacula
BackInTime rsync, diff, meld BackInTime
BackupPC rsync, samba, tar BackupPC
Dar Aucun Dar
Déjà Dup duplicity Duplicity
Grsync rsync Grsync
luckyBackup rsync luckyBackup
SBackup Aucun SBackup

A Faire - Consultez la page List of backup software sur Wikipedia pour plus d'informations.

Ce deuxième tableau compare les outils triés par la date de dernière version connue :

Outil Ecrit en Licence Dernière Version Date Version Linux Windows Mac Site Web
Dar C++ GPL 2.6.2 09/02/2019 Dar
Bacula (Bareos) C, C++ GNU Affero General Public License v3.0 9.4.2 04/02/2019 bacula
BackupPC Perl GPL v3.0 4.3.0 25/11/2018 BackupPC
luckyBackup C++ GPL v3.0 0.5.0 18/11/2018 luckyBackup
Déjà Dup (Duplicity) Python GPL 0.7.18.2 17/11/2018 Duplicity
AMANDA C, Perl GPL, LGPL, Apache, Amanda License 3.5.1 01/12/2017 AMANDA
BackInTime Python3 GPL 1.1.24 07/11/2017 BackInTime
Grsync GTK GPL 1.2.6 15/03/2016 Grsync
Areca Backup Java GPLv2 7.5 26/08/2015 Areca Backup
SBackup GTK GPLv2 0.11.6 24/02/2014 SBackup

Outils de Sauvegarde Multidirectionnelle

Ces outils synchronisent les fichiers entre deux serveurs.

Ce premier tableau compare les outils par rapport aux caractéristiques et aux capacités des opérations de sauvegarde :

Outil Backend Sauvegarde différentielle Sauvegarde incrémentale Sauvegarde décrémentale Planification incorporée Restauration incorporée Chiffrement Compression
FullSync smb, ftp, sftp S/O
FreeFileSync Aucun S/O
unison SSH, RSH S/O
Synkron Aucun

A Faire - Consultez la page Comparison of file synchronization software sur Wikipedia pour plus d'informations..

Ce deuxième tableau compare les outils triés par la date de dernière version connue :

Outil Ecrit en Licence Dernière Version Date Version Linux Windows Mac Site Web
FreeFileSync Divers GPL v3.0 10.8 05/01/2019 FreeFileSync
unison OCaml GPL v3.0 2.51.2 27/01/2018 unison
FullSync Java GPLv2 0.10.4 05/04/2016 FullSync
Synkron C++ GPL v2 1.6.2 25/01/2011 Synkron

Outils de Sauvegarde des Partitions

Ce premier tableau compare les outils par rapport aux caractéristiques et aux capacités des opérations de sauvegarde :

Outil Backend Sauvegarde différentielle Sauvegarde incrémentale Sauvegarde décrémentale Planification incorporée Restauration incorporée Chiffrement Compression
CloneZilla SSH, samba, NFS
Partclone Aucun
partimage Aucun

A Faire - Consultez la page Comparison of disk cloning software sur Wikipedia pour plus d'informations.

Ce deuxième tableau compare les outils triés par la date de dernière version connue :

Outil Ecrit en Licence Dernière Version Date Version Linux Windows Mac Site Web
CloneZilla Perl, Unix shell GPL 2.6.0-37 10/01/2019 CloneZilla
Partclone C GPL 0.2.89 05/07/2016 Partclone
partimage C GPL 0.6.9 25/07/2010 Partimage

LAB #4 - Que Sauvegarder en Priorité ?

4.1 - Sauvegarde de la Liste des Paquets

Utilisez la commande dpkg pour créer un fichier contenant une liste des paquets installés :

root@debian11:/# dpkg --get-selections > liste-des-paquets_`hostname`_`date +%Y-%m-%d-%H-%M`

Consultez le contenu de ce fichier :

root@debian11:/# more liste-des-paquets_debian11_2022-04-28-11-12 
acl                                             install
adduser                                         install
adwaita-icon-theme                              install
alsa-topology-conf                              install
alsa-ucm-conf                                   install
alsa-utils                                      install
anacron                                         install
apparmor                                        install
apt                                             install
apt-listchanges                                 install
apt-utils                                       install
aspell                                          install
aspell-en                                       install
at-spi2-core                                    install
atril                                           install
atril-common                                    install
avahi-daemon                                    install
base-files                                      install
base-passwd                                     install
bash                                            install
bash-completion                                 install
bc                                              install
bind9-dnsutils                                  install
--More--(1%)
[q]

Copiez maintenant le fichier de /etc/apt/sources.list :

root@debian11:/# cp /etc/apt/sources.list sources.list

Important - Il convient ensuite de sauvegarder les deux fichiers liste-des-paquets_* et sources.list sur un support externe.

Afin de restaurer la liste des paquets, récupérez les deux fichiers liste-des-paquets_* et sources.list du support externe.

Restaurez le fichier sources.list :

root@debian11:~# cp sources.list /etc/apt/sources.list

Mettez à jour les listes des paquets disponibles :

root@debian11:~# apt-get update

Mettez à jour l'information sur les paquets disponibles dans dselect :

root@debian11:/# dselect update

Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease
Reading package lists... Done                 
Merging available information
Replacing available packages info, using /var/cache/apt/available.
Information about 58640 packages was updated.

Restaurez le contenu du fichier liste-des-paquets* :

root@debian11:/# dpkg --set-selections < liste-des-paquets_debian11_2022-04-28-11-12

Installez ou mettez à jour tous les paquets dans le fichier liste-des-paquets_* :

root@debian11:/# apt-get -u dselect-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be upgraded:
  libavcodec58 libavfilter7 libavformat58 libavresample4 libavutil56 libpostproc55
  libswresample3 libswscale5
8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 8,146 kB of archives.
After this operation, 8,192 B of additional disk space will be used.
Do you want to continue? [Y/n] y

4.2 - Sauvegarde d'un Mémo sur la Structure du Disque Dur Système

root@debian11:/# cd ~

root@debian11:~# fdisk -l /dev/sdb > structure.list

root@debian11:~# cat structure.list 
Disk /dev/sdb: 32 GiB, 34359738368 bytes, 67108864 sectors
Disk model: QEMU HARDDISK   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf2e3a71a

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdb1  *        2048 65107967 65105920   31G 83 Linux
/dev/sdb2       65110014 67106815  1996802  975M  5 Extended
/dev/sdb5       65110016 67106815  1996800  975M 82 Linux swap / Solaris

Important - Il convient ensuite de sauvegarder le fichier structure.list sur un support externe.

4.3 - Sauvegarde d'un Mémo sur les Points de Montage du Disque Dur Système

Saisissez la commande suivante :

root@debian11:~# df -h | grep "^/dev/" > montages.list

root@debian11:~# cat montages.list 
/dev/sdb1           31G  3.6G   26G  13% /
/dev/sdc12         189M   44K  175M   1% /mnt/sdc12
/dev/mapper/sdc11  459M   14K  431M   1% /mnt/sdc11

Important - Il convient ensuite de sauvegarder le fichier montages.list sur un support externe.

4.4 - Sauvegarde du Chargeur de Démarrage

GRUB Legacy
# cp /boot/grub/menu.lst grubmenu.lst
GRUB 2 avec BIOS

Saisissez les commandes suivantes :

# cp /boot/grub2/grub.cfg grub.cfg
GRUB 2 avec EFI
# cp /boot/efi/EFI/debian/grub.cfg grub.cfg

Important - Il convient ensuite de sauvegarder le fichier menu.lst ou grub.cfg et le fichier device.map sur un support externe.

4.5 - Sauvegarde des Dossiers Utilisateurs

root@debian11:~# cp -apv /home/ .
'/home/' -> './home'
'/home/trainee' -> './home/trainee'
'/home/trainee/.bash_logout' -> './home/trainee/.bash_logout'
'/home/trainee/.bashrc' -> './home/trainee/.bashrc'
'/home/trainee/.profile' -> './home/trainee/.profile'
'/home/trainee/.dmrc' -> './home/trainee/.dmrc'
'/home/trainee/.config' -> './home/trainee/.config'
'/home/trainee/.config/pulse' -> './home/trainee/.config/pulse'
'/home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-device-volumes.tdb' -> './home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-device-volumes.tdb'
'/home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-stream-volumes.tdb' -> './home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-stream-volumes.tdb'
'/home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-card-database.tdb' -> './home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-card-database.tdb'
'/home/trainee/.config/pulse/cookie' -> './home/trainee/.config/pulse/cookie'
'/home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-default-sink' -> './home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-default-sink'
'/home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-default-source' -> './home/trainee/.config/pulse/6f7e96ef32a74c788166a0f3ad41a5c0-default-source'
'/home/trainee/.config/user-dirs.dirs' -> './home/trainee/.config/user-dirs.dirs'
'/home/trainee/.config/user-dirs.locale' -> './home/trainee/.config/user-dirs.locale'
'/home/trainee/.config/xfce4' -> './home/trainee/.config/xfce4'
'/home/trainee/.config/xfce4/xfconf' -> './home/trainee/.config/xfce4/xfconf'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml'
'/home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml' -> './home/trainee/.config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml'
'/home/trainee/.config/xfce4/xfwm4' -> './home/trainee/.config/xfce4/xfwm4'
'/home/trainee/.config/xfce4/panel' -> './home/trainee/.config/xfce4/panel'
'/home/trainee/.config/xfce4/panel/launcher-17' -> './home/trainee/.config/xfce4/panel/launcher-17'
'/home/trainee/.config/xfce4/panel/launcher-17/16508630081.desktop' -> './home/trainee/.config/xfce4/panel/launcher-17/16508630081.desktop'
'/home/trainee/.config/xfce4/panel/launcher-18' -> './home/trainee/.config/xfce4/panel/launcher-18'
'/home/trainee/.config/xfce4/panel/launcher-18/16508630082.desktop' -> './home/trainee/.config/xfce4/panel/launcher-18/16508630082.desktop'
'/home/trainee/.config/xfce4/panel/launcher-19' -> './home/trainee/.config/xfce4/panel/launcher-19'
'/home/trainee/.config/xfce4/panel/launcher-19/16508630083.desktop' -> './home/trainee/.config/xfce4/panel/launcher-19/16508630083.desktop'
'/home/trainee/.config/xfce4/panel/launcher-20' -> './home/trainee/.config/xfce4/panel/launcher-20'
'/home/trainee/.config/xfce4/panel/launcher-20/16508630084.desktop' -> './home/trainee/.config/xfce4/panel/launcher-20/16508630084.desktop'
'/home/trainee/.config/xfce4/desktop' -> './home/trainee/.config/xfce4/desktop'
'/home/trainee/.config/xfce4/desktop/icons.screen0-1008x725.rc' -> './home/trainee/.config/xfce4/desktop/icons.screen0-1008x725.rc'
'/home/trainee/.config/xfce4/desktop/icons.screen.latest.rc' -> './home/trainee/.config/xfce4/desktop/icons.screen.latest.rc'
'/home/trainee/.config/xfce4/terminal' -> './home/trainee/.config/xfce4/terminal'
'/home/trainee/.config/xfce4/terminal/accels.scm' -> './home/trainee/.config/xfce4/terminal/accels.scm'
'/home/trainee/.config/dconf' -> './home/trainee/.config/dconf'
'/home/trainee/.config/dconf/user' -> './home/trainee/.config/dconf/user'
'/home/trainee/.config/pipewire-media-session' -> './home/trainee/.config/pipewire-media-session'
'/home/trainee/.config/Thunar' -> './home/trainee/.config/Thunar'
'/home/trainee/.config/Thunar/uca.xml' -> './home/trainee/.config/Thunar/uca.xml'
'/home/trainee/.Xauthority' -> './home/trainee/.Xauthority'
'/home/trainee/.xsession-errors' -> './home/trainee/.xsession-errors'
'/home/trainee/.cache' -> './home/trainee/.cache'
'/home/trainee/.cache/sessions' -> './home/trainee/.cache/sessions'
'/home/trainee/.cache/gstreamer-1.0' -> './home/trainee/.cache/gstreamer-1.0'
'/home/trainee/.cache/gstreamer-1.0/registry.x86_64.bin' -> './home/trainee/.cache/gstreamer-1.0/registry.x86_64.bin'
'/home/trainee/Desktop' -> './home/trainee/Desktop'
'/home/trainee/Downloads' -> './home/trainee/Downloads'
'/home/trainee/Templates' -> './home/trainee/Templates'
'/home/trainee/Public' -> './home/trainee/Public'
'/home/trainee/Documents' -> './home/trainee/Documents'
'/home/trainee/Music' -> './home/trainee/Music'
'/home/trainee/Pictures' -> './home/trainee/Pictures'
'/home/trainee/Videos' -> './home/trainee/Videos'
'/home/trainee/.local' -> './home/trainee/.local'
'/home/trainee/.local/share' -> './home/trainee/.local/share'
'/home/trainee/.local/share/icc' -> './home/trainee/.local/share/icc'
'/home/trainee/.ICEauthority' -> './home/trainee/.ICEauthority'
'/home/trainee/.gnupg' -> './home/trainee/.gnupg'
'/home/trainee/.gnupg/private-keys-v1.d' -> './home/trainee/.gnupg/private-keys-v1.d'
'/home/trainee/.bash_history' -> './home/trainee/.bash_history'

Important - Il convient ensuite de sauvegarder le dossier /root/home sur un support externe.

LAB #5 - Rsync

5.1 - Présentation

Rsync ou Remote Sync est un utilitaire de synchronisation de fichiers qui utilise un algorithme qui minimise la quantité de données copiée en ne copiant que les parties des fichiers qui ont été modifiées.

5.2 - Travailler avec la Commande rsync

Créez les répertoires /test/repA et mkdir /test/repB :

root@debian11:~# mkdir -p /test/repA; mkdir /test/repB

Créez maintenant 20 fichiers vides dans le répertoire /test/repA :

root@debian11:~# touch /test/repA/file{1..20}

root@debian11:~# ls -l /test/repA/
total 0
-rw-r--r-- 1 root root 0 Apr 28 13:35 file1
-rw-r--r-- 1 root root 0 Apr 28 13:35 file10
-rw-r--r-- 1 root root 0 Apr 28 13:35 file11
-rw-r--r-- 1 root root 0 Apr 28 13:35 file12
-rw-r--r-- 1 root root 0 Apr 28 13:35 file13
-rw-r--r-- 1 root root 0 Apr 28 13:35 file14
-rw-r--r-- 1 root root 0 Apr 28 13:35 file15
-rw-r--r-- 1 root root 0 Apr 28 13:35 file16
-rw-r--r-- 1 root root 0 Apr 28 13:35 file17
-rw-r--r-- 1 root root 0 Apr 28 13:35 file18
-rw-r--r-- 1 root root 0 Apr 28 13:35 file19
-rw-r--r-- 1 root root 0 Apr 28 13:35 file2
-rw-r--r-- 1 root root 0 Apr 28 13:35 file20
-rw-r--r-- 1 root root 0 Apr 28 13:35 file3
-rw-r--r-- 1 root root 0 Apr 28 13:35 file4
-rw-r--r-- 1 root root 0 Apr 28 13:35 file5
-rw-r--r-- 1 root root 0 Apr 28 13:35 file6
-rw-r--r-- 1 root root 0 Apr 28 13:35 file7
-rw-r--r-- 1 root root 0 Apr 28 13:35 file8
-rw-r--r-- 1 root root 0 Apr 28 13:35 file9

Installez ensuite l'exécutable rsync :

root@debian11:~# apt -y install rsync

Pout synchroniser les fichiers de /test/repA vers le répertoire /test/repB, utilisez l'option -r de la commande rsync :

root@debian11:~# rsync -r /test/repA/ /test/repB
root@debian11:~# ls -l /test/repB/
total 0
-rw-r--r-- 1 root root 0 Apr 28 13:36 file1
-rw-r--r-- 1 root root 0 Apr 28 13:36 file10
-rw-r--r-- 1 root root 0 Apr 28 13:36 file11
-rw-r--r-- 1 root root 0 Apr 28 13:36 file12
-rw-r--r-- 1 root root 0 Apr 28 13:36 file13
-rw-r--r-- 1 root root 0 Apr 28 13:36 file14
-rw-r--r-- 1 root root 0 Apr 28 13:36 file15
-rw-r--r-- 1 root root 0 Apr 28 13:36 file16
-rw-r--r-- 1 root root 0 Apr 28 13:36 file17
-rw-r--r-- 1 root root 0 Apr 28 13:36 file18
-rw-r--r-- 1 root root 0 Apr 28 13:36 file19
-rw-r--r-- 1 root root 0 Apr 28 13:36 file2
-rw-r--r-- 1 root root 0 Apr 28 13:36 file20
-rw-r--r-- 1 root root 0 Apr 28 13:36 file3
-rw-r--r-- 1 root root 0 Apr 28 13:36 file4
-rw-r--r-- 1 root root 0 Apr 28 13:36 file5
-rw-r--r-- 1 root root 0 Apr 28 13:36 file6
-rw-r--r-- 1 root root 0 Apr 28 13:36 file7
-rw-r--r-- 1 root root 0 Apr 28 13:36 file8
-rw-r--r-- 1 root root 0 Apr 28 13:36 file9

Important - Notez que l'horodatage des fichiers synchronisés n'a pas été préservé.

Supprimez les fichiers dans /test/repB :

root@debian11:~# rm -rf /test/repB/*

root@debian11:~# ls -l /test/repB/
total 0

Pour synchroniser les fichiers de /test/repA vers le répertoire /test/repB, utilisez l'option -a de la commande rsync :

root@debian11:~# rsync -a /test/repA/ /test/repB

root@debian11:~# ls -l /test/repB/
total 0
-rw-r--r-- 1 root root 0 Apr 28 13:35 file1
-rw-r--r-- 1 root root 0 Apr 28 13:35 file10
-rw-r--r-- 1 root root 0 Apr 28 13:35 file11
-rw-r--r-- 1 root root 0 Apr 28 13:35 file12
-rw-r--r-- 1 root root 0 Apr 28 13:35 file13
-rw-r--r-- 1 root root 0 Apr 28 13:35 file14
-rw-r--r-- 1 root root 0 Apr 28 13:35 file15
-rw-r--r-- 1 root root 0 Apr 28 13:35 file16
-rw-r--r-- 1 root root 0 Apr 28 13:35 file17
-rw-r--r-- 1 root root 0 Apr 28 13:35 file18
-rw-r--r-- 1 root root 0 Apr 28 13:35 file19
-rw-r--r-- 1 root root 0 Apr 28 13:35 file2
-rw-r--r-- 1 root root 0 Apr 28 13:35 file20
-rw-r--r-- 1 root root 0 Apr 28 13:35 file3
-rw-r--r-- 1 root root 0 Apr 28 13:35 file4
-rw-r--r-- 1 root root 0 Apr 28 13:35 file5
-rw-r--r-- 1 root root 0 Apr 28 13:35 file6
-rw-r--r-- 1 root root 0 Apr 28 13:35 file7
-rw-r--r-- 1 root root 0 Apr 28 13:35 file8
-rw-r--r-- 1 root root 0 Apr 28 13:35 file9

Important - Notez que non seulement l'option -a de la commande rsync synchronise les fichiers d'une manière récursive, toute comme l'option -r, mais elle préserve aussi les fichiers spéciaux, les liens symboliques, les permissions, les propriétaires, les groupes ainsi que les dates de modification des fichiers.

De nouveau, supprimez les fichiers dans le répertoire /test/repB :

root@debian11:~# rm -rf /test/repB/*

root@debian11:~# ls -l /test/repB/
total 0

Exécutez maintenant le commande suivante et constatez le résultat :

root@debian11:~# rsync -a /test/repA /test/repB

root@debian11:~# ls -l /test/repB/
total 4
drwxr-xr-x 2 root root 4096 Apr 28 13:35 repA

root@debian11:~# ls -l /test/repB/repA/
total 0
-rw-r--r-- 1 root root 0 Apr 28 13:35 file1
-rw-r--r-- 1 root root 0 Apr 28 13:35 file10
-rw-r--r-- 1 root root 0 Apr 28 13:35 file11
-rw-r--r-- 1 root root 0 Apr 28 13:35 file12
-rw-r--r-- 1 root root 0 Apr 28 13:35 file13
-rw-r--r-- 1 root root 0 Apr 28 13:35 file14
-rw-r--r-- 1 root root 0 Apr 28 13:35 file15
-rw-r--r-- 1 root root 0 Apr 28 13:35 file16
-rw-r--r-- 1 root root 0 Apr 28 13:35 file17
-rw-r--r-- 1 root root 0 Apr 28 13:35 file18
-rw-r--r-- 1 root root 0 Apr 28 13:35 file19
-rw-r--r-- 1 root root 0 Apr 28 13:35 file2
-rw-r--r-- 1 root root 0 Apr 28 13:35 file20
-rw-r--r-- 1 root root 0 Apr 28 13:35 file3
-rw-r--r-- 1 root root 0 Apr 28 13:35 file4
-rw-r--r-- 1 root root 0 Apr 28 13:35 file5
-rw-r--r-- 1 root root 0 Apr 28 13:35 file6
-rw-r--r-- 1 root root 0 Apr 28 13:35 file7
-rw-r--r-- 1 root root 0 Apr 28 13:35 file8
-rw-r--r-- 1 root root 0 Apr 28 13:35 file9

Important - Notez que dans ce cas, le caractère / est manquant après repA dans la commande rsync -a /test/repA /test/repB. Le résultat est la synchronisation du répertoire /test/repA vers /test/repB.

Pour éviter des erreurs, la commande rsync vous permet de visualiser le résultat de votre commande sans exécuter la commande grâce à l'utilisation des options -n et -r.

De nouveau, supprimez les fichiers dans le répertoire /test/repB :

root@debian11:~# rm -rf /test/repB/*

root@debian11:~# ls -l /test/repB/
total 0

Exécutez la commande ci-dessous :

root@debian11:~# rsync -anv /test/repA/ /test/repB
sending incremental file list
./
file1
file10
file11
file12
file13
file14
file15
file16
file17
file18
file19
file2
file20
file3
file4
file5
file6
file7
file8
file9

sent 390 bytes  received 79 bytes  938.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

Important - Notez que dans ce cas, Le résultat de la synchronisation est d'envoyer le contenu du répertoire /test/repA vers /test/repB.

Maintenant, exécutez la commande ci-dessous :

root@debian11:~# rsync -av /test/repA /test/repB
sending incremental file list
repA/
repA/file1
repA/file10
repA/file11
repA/file12
repA/file13
repA/file14
repA/file15
repA/file16
repA/file17
repA/file18
repA/file19
repA/file2
repA/file20
repA/file3
repA/file4
repA/file5
repA/file6
repA/file7
repA/file8
repA/file9

sent 404 bytes  received 80 bytes  968.00 bytes/sec

Important - Notez que dans ce cas, Le résultat de la synchronisation est d'envoyer le répertoire /test/repA vers /test/repB.

Options de la Commande

Les options de la commande rsync sont :

root@debian11:~# rsync --help
rsync  version 3.2.3  protocol version 31
Copyright (C) 1996-2020 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, hardlink-specials, symlinks, IPv6, atimes,
    batchfiles, inplace, append, ACLs, xattrs, optional protect-args, iconv,
    symtimes, prealloc, stop-at, no crtimes
Optimizations:
    SIMD, asm, openssl-crypto
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 none
Compress list:
    zstd lz4 zlibx zlib none

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
--verbose, -v            increase verbosity
--info=FLAGS             fine-grained informational verbosity
--debug=FLAGS            fine-grained debug verbosity
--stderr=e|a|c           change stderr output mode (default: errors)
--quiet, -q              suppress non-error messages
--no-motd                suppress daemon-mode MOTD
--checksum, -c           skip based on checksum, not mod-time & size
--archive, -a            archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
--no-OPTION              turn off an implied OPTION (e.g. --no-D)
--recursive, -r          recurse into directories
--relative, -R           use relative path names
--no-implied-dirs        don't send implied dirs with --relative
--backup, -b             make backups (see --suffix & --backup-dir)
--backup-dir=DIR         make backups into hierarchy based in DIR
--suffix=SUFFIX          backup suffix (default ~ w/o --backup-dir)
--update, -u             skip files that are newer on the receiver
--inplace                update destination files in-place
--append                 append data onto shorter files
--append-verify          --append w/old data in file checksum
--dirs, -d               transfer directories without recursing
--mkpath                 create the destination's path component
--links, -l              copy symlinks as symlinks
--copy-links, -L         transform symlink into referent file/dir
--copy-unsafe-links      only "unsafe" symlinks are transformed
--safe-links             ignore symlinks that point outside the tree
--munge-links            munge symlinks to make them safe & unusable
--copy-dirlinks, -k      transform symlink to dir into referent dir
--keep-dirlinks, -K      treat symlinked dir on receiver as dir
--hard-links, -H         preserve hard links
--perms, -p              preserve permissions
--executability, -E      preserve executability
--chmod=CHMOD            affect file and/or directory permissions
--acls, -A               preserve ACLs (implies --perms)
--xattrs, -X             preserve extended attributes
--owner, -o              preserve owner (super-user only)
--group, -g              preserve group
--devices                preserve device files (super-user only)
--copy-devices           copy device contents as regular file
--specials               preserve special files
-D                       same as --devices --specials
--times, -t              preserve modification times
--atimes, -U             preserve access (use) times
--open-noatime           avoid changing the atime on opened files
--crtimes, -N            preserve create times (newness)
--omit-dir-times, -O     omit directories from --times
--omit-link-times, -J    omit symlinks from --times
--super                  receiver attempts super-user activities
--fake-super             store/recover privileged attrs using xattrs
--sparse, -S             turn sequences of nulls into sparse blocks
--preallocate            allocate dest files before writing them
--write-devices          write to devices as files (implies --inplace)
--dry-run, -n            perform a trial run with no changes made
--whole-file, -W         copy files whole (w/o delta-xfer algorithm)
--checksum-choice=STR    choose the checksum algorithm (aka --cc)
--one-file-system, -x    don't cross filesystem boundaries
--block-size=SIZE, -B    force a fixed checksum block-size
--rsh=COMMAND, -e        specify the remote shell to use
--rsync-path=PROGRAM     specify the rsync to run on remote machine
--existing               skip creating new files on receiver
--ignore-existing        skip updating files that exist on receiver
--remove-source-files    sender removes synchronized files (non-dir)
--del                    an alias for --delete-during
--delete                 delete extraneous files from dest dirs
--delete-before          receiver deletes before xfer, not during
--delete-during          receiver deletes during the transfer
--delete-delay           find deletions during, delete after
--delete-after           receiver deletes after transfer, not during
--delete-excluded        also delete excluded files from dest dirs
--ignore-missing-args    ignore missing source args without error
--delete-missing-args    delete missing source args from destination
--ignore-errors          delete even if there are I/O errors
--force                  force deletion of dirs even if not empty
--max-delete=NUM         don't delete more than NUM files
--max-size=SIZE          don't transfer any file larger than SIZE
--min-size=SIZE          don't transfer any file smaller than SIZE
--max-alloc=SIZE         change a limit relating to memory alloc
--partial                keep partially transferred files
--partial-dir=DIR        put a partially transferred file into DIR
--delay-updates          put all updated files into place at end
--prune-empty-dirs, -m   prune empty directory chains from file-list
--numeric-ids            don't map uid/gid values by user/group name
--usermap=STRING         custom username mapping
--groupmap=STRING        custom groupname mapping
--chown=USER:GROUP       simple username/groupname mapping
--timeout=SECONDS        set I/O timeout in seconds
--contimeout=SECONDS     set daemon connection timeout in seconds
--ignore-times, -I       don't skip files that match size and time
--size-only              skip files that match in size
--modify-window=NUM, -@  set the accuracy for mod-time comparisons
--temp-dir=DIR, -T       create temporary files in directory DIR
--fuzzy, -y              find similar file for basis if no dest file
--compare-dest=DIR       also compare destination files relative to DIR
--copy-dest=DIR          ... and include copies of unchanged files
--link-dest=DIR          hardlink to files in DIR when unchanged
--compress, -z           compress file data during the transfer
--compress-choice=STR    choose the compression algorithm (aka --zc)
--compress-level=NUM     explicitly set compression level (aka --zl)
--skip-compress=LIST     skip compressing files with suffix in LIST
--cvs-exclude, -C        auto-ignore files in the same way CVS does
--filter=RULE, -f        add a file-filtering RULE
-F                       same as --filter='dir-merge /.rsync-filter'
                         repeated: --filter='- .rsync-filter'
--exclude=PATTERN        exclude files matching PATTERN
--exclude-from=FILE      read exclude patterns from FILE
--include=PATTERN        don't exclude files matching PATTERN
--include-from=FILE      read include patterns from FILE
--files-from=FILE        read list of source-file names from FILE
--from0, -0              all *-from/filter files are delimited by 0s
--protect-args, -s       no space-splitting; wildcard chars only
--copy-as=USER[:GROUP]   specify user & optional group for the copy
--address=ADDRESS        bind address for outgoing socket to daemon
--port=PORT              specify double-colon alternate port number
--sockopts=OPTIONS       specify custom TCP options
--blocking-io            use blocking I/O for the remote shell
--outbuf=N|L|B           set out buffering to None, Line, or Block
--stats                  give some file-transfer stats
--8-bit-output, -8       leave high-bit chars unescaped in output
--human-readable, -h     output numbers in a human-readable format
--progress               show progress during transfer
-P                       same as --partial --progress
--itemize-changes, -i    output a change-summary for all updates
--remote-option=OPT, -M  send OPTION to the remote side only
--out-format=FORMAT      output updates using the specified FORMAT
--log-file=FILE          log what we're doing to the specified FILE
--log-file-format=FMT    log updates using the specified FMT
--password-file=FILE     read daemon-access password from FILE
--early-input=FILE       use FILE for daemon's early exec input
--list-only              list the files instead of copying them
--bwlimit=RATE           limit socket I/O bandwidth
--stop-after=MINS        Stop rsync after MINS minutes have elapsed
--stop-at=y-m-dTh:m      Stop rsync at the specified point in time
--write-batch=FILE       write a batched update to FILE
--only-write-batch=FILE  like --write-batch but w/o updating dest
--read-batch=FILE        read a batched update from FILE
--protocol=NUM           force an older protocol version to be used
--iconv=CONVERT_SPEC     request charset conversion of filenames
--checksum-seed=NUM      set block/file checksum seed (advanced)
--ipv4, -4               prefer IPv4
--ipv6, -6               prefer IPv6
--version, -V            print the version + other info and exit
--help, -h (*)           show this help (* -h is help only on its own)

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See https://rsync.samba.org/ for updates, bug reports, and answers

LAB #6 - Commandes Diverses

6.1- La Commande wall

La commande wall envoie un message à tous les utilisateurs connectés dont l’autorisation mesg(1) est positionnée à yes. Le message peut être fourni en tant qu’argument sur la ligne de commande, ou il peut être envoyé sur l’entrée standard de wall.

Envoyez un message :

trainee@debian11:~$ su -
Password: fenestros
root@debian11:~# wall this is a message from root
                                                                               
Broadcast message from trainee@debian11 (pts/1) (Thu Jun  2 11:09:04 2022):    
                                                                               
this is a message from root
                                                                               
root@debian11:~#

A faire : Utilisez l'option –help de la commande wall pour visualiser les options de la commande.

6.2 - La commande patch

La commande patch est utilisée pour appliquer des modifications à un fichier à partir d'un fichier patch qui contient les différences entre le contenu de l'ancienne version du fichier et la nouvelle version.

La commande patch n'est pas installée par défaut sous Debian 11 :

root@debian11:~# which patch
root@debian11:~#
root@debian11:~# apt install patch -y

Créez les fichiers /tmp/greptest et /tmp/greptest1 :

root@debian11:~# cat /tmp/greptest
# Starting comment
^ This line will be used to demonstrate the use of fgrep
fenestrOS
fenestros
# Another comment
555-5555
f

.fenestros

.fe

£
# End comment

root@debian11:~# cat /tmp/greptest1
fenestrOS
fenestros
555-5555
f
.fenestros
.fe
£

Afin de créer un fichier de patch, il convient d'utiliser la commande diff avec l'option -u

root@debian11:~# cd /tmp
root@debian11:/tmp# diff -u greptest greptest1 > greptest.patch

L'examen du fichier de patch démontre les modifications à apporter au fichier greptest :

root@debian11:/tmp# cat greptest.patch
--- greptest    2022-06-02 14:13:47.823779461 +0200
+++ greptest1   2022-06-02 14:12:30.019484987 +0200
@@ -1,14 +1,7 @@
-# Starting comment
-^ This line will be used to demonstrate the use of fgrep
 fenestrOS
 fenestros
-# Another comment
 555-5555
 f
-
 .fenestros
-
 .fe
-
 £
-# End comment

Procédez maintenant à l'application du fichier patch :

root@debian11:/tmp# patch < greptest.patch
patching file greptest

Contrôlez maintenant le contenu du fichier greptest :

root@debian11:/tmp# cat greptest
fenestrOS
fenestros
555-5555
f
.fenestros
.fe
£

A faire : Utilisez l'option –help de la commande patch pour visualiser les options de la commande.

LAB #7 - Compiler à partir des sources

Historiquement il était nécessaire d'installer un logiciel à partir de ses fichiers sources.

Pour commencer, installez les outils dont vous aurez besoin :

root@debian11:~# apt-get -y install gcc

Pour comprendre ce qui est la compilation d'un logiciel, commencez par télécharger le logiciel hello :

root@debian11:~# wget --no-check-certificate https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz
--2022-04-25 13:38:57--  https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz
Resolving ftp.gnu.org (ftp.gnu.org)... 209.51.188.20, 2001:470:142:3::b
Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 389363 (380K) [application/x-gzip]
Saving to: ‘hello-2.1.1.tar.gz’

hello-2.1.1.tar.gz                                   100%[====================================================================================================================>] 380.24K   864KB/s    in 0.4s    

2022-04-25 13:38:58 (864 KB/s) - ‘hello-2.1.1.tar.gz’ saved [389363/389363]

Ensuite désarchivez le logiciel :

root@debian11:~# tar xvf hello-2.1.1.tar.gz

Changez de répertoire :

root@debian11:~# cd hello-2.1.1/
root@debian11:~/hello-2.1.1# ls
ABOUT-NLS   AUTHORS  ChangeLog    config.guess  config.rpath  configure     contrib  depcomp  INSTALL     intl  Makefile.am  man      mkinstalldirs  po      src    THANKS
aclocal.m4  BUGS     ChangeLog.O  config.h.in   config.sub    configure.ac  COPYING  doc      install-sh  m4    Makefile.in  missing  NEWS           README  tests  TODO

A l'étude du fichier README, celui-ci nous renvoie vers le fichier INSTALL :

root@debian11:~/hello-2.1.1# cat README 
We are pleased to announce the version 2.1 release of GNU Hello.
All reported bugs in previous test releases have been fixed.
Some bugs surely remain.

The GNU implementation of this classic program is brought to you by
the efforts of several people, including Mike Haertel, David MacKenzie,
Jan Brittenson, Roland McGrath, Charles Hannum, and The King.

The basic algorithm is described in: "The C Programming Language", by
B. W. Kernighan and D. M. Ritchie, Prentice-Hall, New Jersey, 1978;
the program is an enhancement of the one published in that book.

See the file INSTALL for building and installation instructions.

Please send all bug reports by electronic mail to:
    bug-gnu-hello@gnu.org

GNU Hello is free software.  See the file COPYING for copying conditions.

Visualisez donc ce dernier :

root@debian11:~/hello-2.1.1# more INSTALL
Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software Foundation,
Inc.

   This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.

Basic Installation
==================

   These are generic installation instructions.

   The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation.  It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions.  Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').

   It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring.  (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)

   If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release.  If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.

   The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'.  You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.

The simplest way to compile this package is:

  1. `cd' to the directory containing the package's source code and type
     `./configure' to configure the package for your system.  If you're
     using `csh' on an old version of System V, you might need to type
     `sh ./configure' instead to prevent `csh' from trying to execute
     `configure' itself.

     Running `configure' takes awhile.  While running, it prints some
     messages telling which features it is checking for.

  2. Type `make' to compile the package.

  3. Optionally, type `make check' to run any self-tests that come with
     the package.

  4. Type `make install' to install the programs and any data files and
     documentation.

  5. You can remove the program binaries and object files from the
--More--(26%)
[q] <<<<<<<<<<<< Appuyez sur la touche q

La procédure expliquée est celle utilisée pour la plupart des installations manuelles, à savoir la saisie des quatre commandes suivantes.

7.1 - ./configure

Important : configure est un script chargé de créer les makefiles pour une architecture donnée. Les makefiles sont lus par la commande make.

root@debian11:~/hello-2.1.1# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets ${MAKE}... no
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for style of include used by make... none
checking dependency style of gcc... none
checking for strerror in -lcposix... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for struct stat.st_blksize... yes
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking build system type... x86_64-unknown-linux
checking host system type... x86_64-unknown-linux
checking for ranlib... ranlib
checking for gcc option to accept ANSI C... none needed
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for off_t... yes
checking for size_t... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... yes
checking whether we are using the GNU C Library 2.1 or newer... yes
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... yes
checking argz.h usability... yes
checking argz.h presence... yes
checking for argz.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking nl_types.h usability... yes
checking nl_types.h presence... yes
checking for nl_types.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... (cached) yes
checking for feof_unlocked... yes
checking for fgets_unlocked... yes
checking for getc_unlocked... yes
checking for getcwd... yes
checking for getegid... yes
checking for geteuid... yes
checking for getgid... yes
checking for getuid... yes
checking for mempcpy... yes
checking for munmap... yes
checking for putenv... yes
checking for setenv... yes
checking for setlocale... yes
checking for stpcpy... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strtoul... yes
checking for tsearch... yes
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for iconv declaration... 
         extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for bison... no
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for GNU gettext in libc... yes
checking for perl... perl
configure: creating ./config.status
config.status: creating Makefile
config.status: creating contrib/Makefile
config.status: creating doc/Makefile
config.status: creating intl/Makefile
config.status: creating man/Makefile
config.status: creating po/Makefile.in
config.status: creating m4/Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing default commands

7.2 - make

Important : make sert à appeler des commandes créant des fichiers nécessaires à l'installation du logiciel.

Notez que la commande make n'est pas installée. Installez la commande :

root@debian11:~/hello-2.1.1# make
-bash: make: command not found
root@debian11:~/hello-2.1.1# which make
root@debian11:~/hello-2.1.1# apt install y make

Exécutez maintenant la commande make :

root@debian11:~/hello-2.1.1# make
make  all-recursive
make[1]: Entering directory '/root/hello-2.1.1'
Making all in contrib
make[2]: Entering directory '/root/hello-2.1.1/contrib'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/contrib'
Making all in doc
make[2]: Entering directory '/root/hello-2.1.1/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/doc'
Making all in intl
make[2]: Entering directory '/root/hello-2.1.1/intl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/intl'
Making all in po
make[2]: Entering directory '/root/hello-2.1.1/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/po'
Making all in src
make[2]: Entering directory '/root/hello-2.1.1/src'
source='hello.c' object='hello.o' libtool=no \
depfile='.deps/hello.Po' tmpdepfile='.deps/hello.TPo' \
depmode=none /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'hello.c' || echo './'`hello.c
source='version.c' object='version.o' libtool=no \
depfile='.deps/version.Po' tmpdepfile='.deps/version.TPo' \
depmode=none /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'version.c' || echo './'`version.c
source='getopt.c' object='getopt.o' libtool=no \
depfile='.deps/getopt.Po' tmpdepfile='.deps/getopt.TPo' \
depmode=none /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'getopt.c' || echo './'`getopt.c
source='getopt1.c' object='getopt1.o' libtool=no \
depfile='.deps/getopt1.Po' tmpdepfile='.deps/getopt1.TPo' \
depmode=none /bin/bash ../depcomp \
gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl    -g -O2 -c `test -f 'getopt1.c' || echo './'`getopt1.c
gcc  -g -O2   -o hello  hello.o version.o getopt.o getopt1.o  
make[2]: Leaving directory '/root/hello-2.1.1/src'
Making all in man
make[2]: Entering directory '/root/hello-2.1.1/man'
perl help2man --name="Friendly Greeting Program" ../src/hello >hello.1
make[2]: Leaving directory '/root/hello-2.1.1/man'
Making all in m4
make[2]: Entering directory '/root/hello-2.1.1/m4'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/m4'
Making all in tests
make[2]: Entering directory '/root/hello-2.1.1/tests'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/hello-2.1.1/tests'
make[2]: Entering directory '/root/hello-2.1.1'
make[2]: Leaving directory '/root/hello-2.1.1'
make[1]: Leaving directory '/root/hello-2.1.1'

7.3 - make check

Important : make check permet de vérifier si la commande make a bien fonctionné.

root@debian11:~/hello-2.1.1# make check
Making check in contrib
make[1]: Entering directory '/root/hello-2.1.1/contrib'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/contrib'
Making check in doc
make[1]: Entering directory '/root/hello-2.1.1/doc'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/doc'
Making check in intl
make[1]: Entering directory '/root/hello-2.1.1/intl'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/intl'
Making check in po
make[1]: Entering directory '/root/hello-2.1.1/po'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/po'
Making check in src
make[1]: Entering directory '/root/hello-2.1.1/src'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/src'
Making check in man
make[1]: Entering directory '/root/hello-2.1.1/man'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/man'
Making check in m4
make[1]: Entering directory '/root/hello-2.1.1/m4'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/root/hello-2.1.1/m4'
Making check in tests
make[1]: Entering directory '/root/hello-2.1.1/tests'
make  check-TESTS
make[2]: Entering directory '/root/hello-2.1.1/tests'
PASS: hello-1
PASS: world-1
PASS: nothing-1
==================
All 3 tests passed
==================
make[2]: Leaving directory '/root/hello-2.1.1/tests'
make[1]: Leaving directory '/root/hello-2.1.1/tests'
make[1]: Entering directory '/root/hello-2.1.1'
make[1]: Leaving directory '/root/hello-2.1.1'

7.4 - make install

Important : make install sert à installer le logiciel.

root@debian11:~/hello-2.1.1# make install
Making install in contrib
make[1]: Entering directory '/root/hello-2.1.1/contrib'
make[2]: Entering directory '/root/hello-2.1.1/contrib'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/hello-2.1.1/contrib'
make[1]: Leaving directory '/root/hello-2.1.1/contrib'
Making install in doc
make[1]: Entering directory '/root/hello-2.1.1/doc'
make[2]: Entering directory '/root/hello-2.1.1/doc'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/bash ../mkinstalldirs /usr/local/info
mkdir -p -- /usr/local/info
 /usr/bin/install -c -m 644 ./hello.info /usr/local/info/hello.info
make[2]: Leaving directory '/root/hello-2.1.1/doc'
make[1]: Leaving directory '/root/hello-2.1.1/doc'
Making install in intl
make[1]: Entering directory '/root/hello-2.1.1/intl'
if test "hello" = "gettext" \
   && test '' = 'intl-compat.o'; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib /usr/local/include; \
  /usr/bin/install -c -m 644 libintl.h /usr/local/include/libintl.h; \
  @LIBTOOL@ --mode=install \
    /usr/bin/install -c -m 644 libintl.a /usr/local/lib/libintl.a; \
else \
  : ; \
fi
if test 'no' = yes; then \
  test yes != no || /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib; \
  temp=/usr/local/lib/t-charset.alias; \
  dest=/usr/local/lib/charset.alias; \
  if test -f /usr/local/lib/charset.alias; then \
    orig=/usr/local/lib/charset.alias; \
    sed -f ref-add.sed $orig > $temp; \
    /usr/bin/install -c -m 644 $temp $dest; \
    rm -f $temp; \
  else \
    if test yes = no; then \
      orig=charset.alias; \
      sed -f ref-add.sed $orig > $temp; \
      /usr/bin/install -c -m 644 $temp $dest; \
      rm -f $temp; \
    fi; \
  fi; \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/locale; \
  test -f /usr/local/share/locale/locale.alias \
    && orig=/usr/local/share/locale/locale.alias \
    || orig=./locale.alias; \
  temp=/usr/local/share/locale/t-locale.alias; \
  dest=/usr/local/share/locale/locale.alias; \
  sed -f ref-add.sed $orig > $temp; \
  /usr/bin/install -c -m 644 $temp $dest; \
  rm -f $temp; \
else \
  : ; \
fi
if test "hello" = "gettext"; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/intl; \
  /usr/bin/install -c -m 644 VERSION /usr/local/share/gettext/intl/VERSION; \
  /usr/bin/install -c -m 644 ChangeLog.inst /usr/local/share/gettext/intl/ChangeLog; \
  dists="COPYING.LIB-2.0 COPYING.LIB-2.1 Makefile.in config.charset locale.alias ref-add.sin ref-del.sin gmo.h gettextP.h hash-string.h plural-exp.h eval-plural.h os2compat.h libgnuintl.h loadinfo.h bindtextdom.c dcgettext.c dgettext.c gettext.c finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y plural-exp.c localcharset.c localename.c osdep.c os2compat.c intl-compat.c"; \
  for file in $dists; do \
    /usr/bin/install -c -m 644 ./$file \
                    /usr/local/share/gettext/intl/$file; \
  done; \
  chmod a+x /usr/local/share/gettext/intl/config.charset; \
  dists="plural.c"; \
  for file in $dists; do \
    if test -f $file; then dir=.; else dir=.; fi; \
    /usr/bin/install -c -m 644 $dir/$file \
                    /usr/local/share/gettext/intl/$file; \
  done; \
  dists="xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c COPYING.LIB-2 gettext.h libgettext.h plural-eval.c"; \
  for file in $dists; do \
    rm -f /usr/local/share/gettext/intl/$file; \
  done; \
else \
  : ; \
fi
make[1]: Leaving directory '/root/hello-2.1.1/intl'
Making install in po
make[1]: Entering directory '/root/hello-2.1.1/po'
/bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share
mkdir -p -- /usr/local/share/locale/ca/LC_MESSAGES
installing ca.gmo as /usr/local/share/locale/ca/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/da/LC_MESSAGES
installing da.gmo as /usr/local/share/locale/da/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/de/LC_MESSAGES
installing de.gmo as /usr/local/share/locale/de/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/de_DE/LC_MESSAGES
installing de_DE.gmo as /usr/local/share/locale/de_DE/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/el/LC_MESSAGES
installing el.gmo as /usr/local/share/locale/el/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/eo/LC_MESSAGES
installing eo.gmo as /usr/local/share/locale/eo/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/es/LC_MESSAGES
installing es.gmo as /usr/local/share/locale/es/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/et/LC_MESSAGES
installing et.gmo as /usr/local/share/locale/et/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/fi/LC_MESSAGES
installing fi.gmo as /usr/local/share/locale/fi/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/fr/LC_MESSAGES
installing fr.gmo as /usr/local/share/locale/fr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/gl/LC_MESSAGES
installing gl.gmo as /usr/local/share/locale/gl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/he/LC_MESSAGES
installing he.gmo as /usr/local/share/locale/he/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/hr/LC_MESSAGES
installing hr.gmo as /usr/local/share/locale/hr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/hu/LC_MESSAGES
installing hu.gmo as /usr/local/share/locale/hu/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/id/LC_MESSAGES
installing id.gmo as /usr/local/share/locale/id/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/it/LC_MESSAGES
installing it.gmo as /usr/local/share/locale/it/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ja/LC_MESSAGES
installing ja.gmo as /usr/local/share/locale/ja/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ko/LC_MESSAGES
installing ko.gmo as /usr/local/share/locale/ko/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/lv/LC_MESSAGES
installing lv.gmo as /usr/local/share/locale/lv/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nb/LC_MESSAGES
installing nb.gmo as /usr/local/share/locale/nb/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nl/LC_MESSAGES
installing nl.gmo as /usr/local/share/locale/nl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/nn/LC_MESSAGES
installing nn.gmo as /usr/local/share/locale/nn/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pl/LC_MESSAGES
installing pl.gmo as /usr/local/share/locale/pl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pt/LC_MESSAGES
installing pt.gmo as /usr/local/share/locale/pt/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/pt_BR/LC_MESSAGES
installing pt_BR.gmo as /usr/local/share/locale/pt_BR/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/ru/LC_MESSAGES
installing ru.gmo as /usr/local/share/locale/ru/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sk/LC_MESSAGES
installing sk.gmo as /usr/local/share/locale/sk/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sl/LC_MESSAGES
installing sl.gmo as /usr/local/share/locale/sl/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/sv/LC_MESSAGES
installing sv.gmo as /usr/local/share/locale/sv/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/tr/LC_MESSAGES
installing tr.gmo as /usr/local/share/locale/tr/LC_MESSAGES/hello.mo
mkdir -p -- /usr/local/share/locale/uk/LC_MESSAGES
installing uk.gmo as /usr/local/share/locale/uk/LC_MESSAGES/hello.mo
if test "hello" = "gettext"; then \
  /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/po; \
  for file in Makefile.in.in Makevars remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot  ; do \
    /usr/bin/install -c -m 644 ./$file \
                    /usr/local/share/gettext/po/$file; \
  done; \
else \
  : ; \
fi
make[1]: Leaving directory '/root/hello-2.1.1/po'
Making install in src
make[1]: Entering directory '/root/hello-2.1.1/src'
make[2]: Entering directory '/root/hello-2.1.1/src'
/bin/bash ../mkinstalldirs /usr/local/bin
  /usr/bin/install -c hello /usr/local/bin/hello
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/hello-2.1.1/src'
make[1]: Leaving directory '/root/hello-2.1.1/src'
Making install in man
make[1]: Entering directory '/root/hello-2.1.1/man'
make[2]: Entering directory '/root/hello-2.1.1/man'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/bash ../mkinstalldirs /usr/local/man/man1
mkdir -p -- /usr/local/man/man1
 /usr/bin/install -c -m 644 ./hello.1 /usr/local/man/man1/hello.1
make[2]: Leaving directory '/root/hello-2.1.1/man'
make[1]: Leaving directory '/root/hello-2.1.1/man'
Making install in m4
make[1]: Entering directory '/root/hello-2.1.1/m4'
make[2]: Entering directory '/root/hello-2.1.1/m4'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/hello-2.1.1/m4'
make[1]: Leaving directory '/root/hello-2.1.1/m4'
Making install in tests
make[1]: Entering directory '/root/hello-2.1.1/tests'
make[2]: Entering directory '/root/hello-2.1.1/tests'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/hello-2.1.1/tests'
make[1]: Leaving directory '/root/hello-2.1.1/tests'
make[1]: Entering directory '/root/hello-2.1.1'
make[2]: Entering directory '/root/hello-2.1.1'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/root/hello-2.1.1'
make[1]: Leaving directory '/root/hello-2.1.1'

Il convient maintenant de tester le nouveau logiciel :

root@debian11:~/hello-2.1.1# hello
Hello, world!

Le logiciel hello a été correctement installé.

Fichiers Divers

/etc/motd

Le fichier /etc/motd est un fichier de texte ASCII dont le contenu est affiché par login avant d'exécuter le shell. Motd signifie « message of the day », et il contient généralement des messages destinés aux utilisateurs concernant l'administration du système (ajout de périphériques, arrêts prévus du système, nouvelles versions de logiciels, etc…). Il nécessite nettement moins d'espace disque qu'un courrier électronique envoyé à tous les utilisateurs.

trainee@debian11:~$ cat /etc/motd

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

/etc/issue

Le fichier /etc/issue est un fichier de texte qui accepte certaines séquences d'échappement (voir plus bas) pour insérer des informations sur le système. Les séquences suivantes sont reconnues par agetty (le programme qui analyse en général /etc/issue). Ces informations proviennent de man agetty.

Il existe aussi le fichier issue.net pouvant être utilisé lors de connexions à distance. Néanmoins, SSH va l'utiliser uniquement si vous avez activé l'option adéquate dans les fichiers de configuration et ne va pas interpréter les séquences d'échappement indiquées ci-dessous.

Toutes les séquences d'échappement sont constituées d'un backslash (\) immédiatement suivi d'une des lettres expliquées ci-dessous (donc \d dans /etc/issue insère la date courante).

b   Insérer la vitesse de la ligne.
d   Insérer la date courante.
s   Insérer le nom du système, le nom du système d'exploitation.
l   Insérer le nom de la ligne tty courante.
m   Insérer l'identifiant de l'architecture de la machine, par exemple i486
n   Insérer le nom du noeud de la machine, aussi connu sous le nom de nom
    d'hôte.
o   Insérer le nom de domaine de la machine.
r   Insérer le numéro de version du noyau, par exemple 2.4.16.
t   Insérer la date courante.
u   Insérer le nombre d'utilisateurs connectés en ce moment.
U   Insérer la phrase "1 user" ou "<n> users" où <n> est le nombre
    d'utilisateurs actuellement connectés.
v   Insérer la version de l'OS, par exemple la date de construction.

Copyright © 2022 Hugh Norris.

Menu