Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:lpic:21:450:l103 [2022/10/07 09:39] – created adminelearning:workbooks:lpic:21:450:l103 [2022/11/01 07:24] (Version actuelle) admin
Ligne 5: Ligne 5:
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======Topic 3: System Startup======+======Topic 202: System Startup======
  
-=====Contenu du Module===== +  * **Topic 202: System Startup**
- +
-  * **Topic 3: System Startup** +
-    * Contenu du Module+
     * Présentation     * Présentation
     * BIOS, EFI et OpenFirmware     * BIOS, EFI et OpenFirmware
Ligne 27: Ligne 24:
         * Configurer l'Authentification         * Configurer l'Authentification
         * Modifier la Configuration de GRUB Legacy en Ligne de Commande         * Modifier la Configuration de GRUB Legacy en Ligne de Commande
-      * GRUB 2 sous RHEL/CentOS 7 +      * GRUB 2 sous Debian 11 
-        * Le fichier /boot/grub/device.map+        * Le fichier /boot/grub2/device.map
         * Le fichier /etc/default/grub         * Le fichier /etc/default/grub
         * Les fichiers du répertoire /etc/grub.d         * Les fichiers du répertoire /etc/grub.d
-        * Configurer l'Authentification 
-          * RHEL/CentOS < 7.2 
-          * RHEL/CentOS >= 7.2 
         * Modifier la Configuration de GRUB 2 en Ligne de Commande         * Modifier la Configuration de GRUB 2 en Ligne de Commande
       * Chargeurs de Démarrages Alternatifs       * Chargeurs de Démarrages Alternatifs
Ligne 48: Ligne 42:
       * Le script init       * Le script init
       * La Commande dracut       * La Commande dracut
-    * Initramfs sous RHEL/CentOS 7 +    * Initramfs sous Debian 11 
-      * Examiner l'image existante +      * LAB #1 - Travailler avec Initramfs 
-      * Le script init +        * 1.1 - Examiner l'image existante 
-      * Consulter le contenu d'un fichier dans initramfs +        1.2 - La Commande mkinitramfs
-      * La Commande dracut+
     * Processus de Démarrage du Noyau Linux     * Processus de Démarrage du Noyau Linux
     * Processus Init     * Processus Init
Ligne 93: Ligne 86:
         * La Commande stop         * La Commande stop
         * La Commande restart         * La Commande restart
-    * Démarrer RHEL/CentOS 7 +    * Démarrer Debian 11 avec systemd 
-      * La Commande systemctl +      * LAB #2 - La Commande systemctl 
-      * Fichiers de Configuration +      * LAB #3 - Fichiers de Configuration 
-      * La Commande systemd-analyze +        * 3.1 - Fichiers de Configuration par Défaut 
-      * Gestion des Services +        * 3.2 - Surchargement des Fichiers par Défaut 
-    Arrêt Système du Système +        * 3.3 - Les Fichiers d'Unités 
-      * La Commande shutdown +      * LAB #4 - La Commande systemd-analyze 
-      * La Commande reboot +      * LAB #5 - Les Cibles 
-      La Commande halt +        5.1 - Contrôler les dépendances d'une Cible 
-      La Commande poweroff+        5.2 - La Cible par Défaut 
 +      * LAB #6 - Gestion des Services 
 +        6.1 - Gestion des Instances Uniques 
 +        6.2 - Gestion d'Instances Multiples 
 +        * 6.3 - Interdire la Modification du Statut d'un Service
  
 =====Présentation===== =====Présentation=====
Ligne 149: Ligne 146:
 </WRAP> </WRAP>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : L'UEFI gère parfaitement les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (//Non-Volatile Memory Express//). Linux supporte les SSD depuis le noyau 3.3. **Important** : L'UEFI gère parfaitement les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (//Non-Volatile Memory Express//). Linux supporte les SSD depuis le noyau 3.3.
 </WRAP> </WRAP>
Ligne 204: Ligne 201:
 Si le BIOS signale une erreur lorsque LILO essaye de charger une image d'amorce, le code d'erreur correspondant est affiché. Ces codes vont de 0x00 à 0xbb. Reportez-vous au Guide Utilisateur de LILO pour leur explication. Si le BIOS signale une erreur lorsque LILO essaye de charger une image d'amorce, le code d'erreur correspondant est affiché. Ces codes vont de 0x00 à 0xbb. Reportez-vous au Guide Utilisateur de LILO pour leur explication.
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : LILO ne gère pas les systèmes UEFI. **Important** : LILO ne gère pas les systèmes UEFI.
 </WRAP>  </WRAP> 
Ligne 271: Ligne 268:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s'appelle **grub.conf**. **Important** : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s'appelle **grub.conf**.
 </WRAP>  </WRAP> 
Ligne 355: Ligne 352:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Notez l'addition de la ligne **password --md5 $1$VLOzG$ibdk0my4IHny/XtNIGRhv1** ainsi que le mot clef **lock** sur une ligne située après chaque ligne commençant par **title**.  **Important** : Notez l'addition de la ligne **password --md5 $1$VLOzG$ibdk0my4IHny/XtNIGRhv1** ainsi que le mot clef **lock** sur une ligne située après chaque ligne commençant par **title**. 
 </WRAP> </WRAP>
Ligne 375: Ligne 372:
   * **echap** : abandonner les modifications et retourner à l'interface de GRUB.   * **echap** : abandonner les modifications et retourner à l'interface de GRUB.
  
-====GRUB 2 sous RHEL/CentOS 7====+====GRUB 2 sous Debian 11====
  
 GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, notamment GRUB 2 sait utiliser des partitions RAID et LVM. GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, notamment GRUB 2 sait utiliser des partitions RAID et LVM.
Ligne 383: Ligne 380:
   * Etape 1 : Le **boot.img**, stocké dans les 512 premiers octets du secteur 0 avec la table des partitions, est lancé. Son seul but est de lancer l'étape 1.5,   * Etape 1 : Le **boot.img**, stocké dans les 512 premiers octets du secteur 0 avec la table des partitions, est lancé. Son seul but est de lancer l'étape 1.5,
   * Etape 1.5 : Le **core.img**, d'une taille approximative de 25 Ko et stocké dans les secteurs 1 à 62, est lance. Son travail est de charger des pilotes qui supportent de multiples systèmes de fichiers puis de lancer l'étape 2 dans un des systèmes de fichiers,   * Etape 1.5 : Le **core.img**, d'une taille approximative de 25 Ko et stocké dans les secteurs 1 à 62, est lance. Son travail est de charger des pilotes qui supportent de multiples systèmes de fichiers puis de lancer l'étape 2 dans un des systèmes de fichiers,
-  * Etape 2 : Contenu dans le répertoire **/boot/grub2/**, il lance le menu pour que l'utilisateur puisse choisir les système d'exploitation à lancer.+  * Etape 2 : Contenu dans le répertoire **/boot/grub/**, il lance le menu pour que l'utilisateur puisse choisir les système d'exploitation à lancer.
  
 Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante : Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante :
  
-  # grub2-install /dev/périphérique [Entrée]+  # grub-install /dev/périphérique [Entrée]
  
 où **périphérique** est le nom du périphérique ou l'étape 1 de GRUB2 doit s'installer dans le MBR.  où **périphérique** est le nom du périphérique ou l'étape 1 de GRUB2 doit s'installer dans le MBR. 
  
-**GRUB 2** lit ses entrées de menus à partir du fichier **/boot/grub2/grub.cfg**. Pour visualiser ce fichier, il convient de saisir la commande suivante :+**GRUB 2** lit ses entrées de menus à partir du fichier **/boot/grub/grub.cfg**. Pour visualiser ce fichier, il convient de saisir la commande suivante :
  
 <code> <code>
-[root@centos7 ~]# cat /boot/grub2/grub.cfg +root@debian11:~# cat /boot/grub/grub.cfg
 # #
 # DO NOT EDIT THIS FILE # DO NOT EDIT THIS FILE
 # #
-# It is automatically generated by grub2-mkconfig using templates+# It is automatically generated by grub-mkconfig using templates
 # from /etc/grub.d and settings from /etc/default/grub # from /etc/grub.d and settings from /etc/default/grub
 # #
  
 ### BEGIN /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/00_header ###
-set pager=1 
- 
 if [ -s $prefix/grubenv ]; then if [ -s $prefix/grubenv ]; then
 +  set have_grubenv=true
   load_env   load_env
 fi fi
Ligne 414: Ligne 410:
    set boot_once=true    set boot_once=true
 else else
-   set default="${saved_entry}"+   set default="0"
 fi fi
  
Ligne 439: Ligne 435:
   fi   fi
 } }
- 
 function load_video { function load_video {
   if [ x$feature_all_video_module = xy ]; then   if [ x$feature_all_video_module = xy ]; then
Ligne 454: Ligne 449:
 } }
  
-terminal_output console +if [ x$feature_default_font_path = xy ] ; then 
-if [ x$feature_timeout_style = xy ] ; then +   font=unicode
-  set timeout_style=menu +
-  set timeout=5 +
-# Fallback normal timeout code in case the timeout_style feature is +
-# unavailable.+
 else else
-  set timeout=5+insmod part_msdos 
 +insmod ext2 
 +set root='hd0,msdos1' 
 +if [ x$feature_platform_search_hint = xy ]; then 
 +  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e 
 +else 
 +  search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e 
 +fi 
 +    font="/usr/share/grub/unicode.pf2" 
 +fi 
 + 
 +if loadfont $font ; then 
 +  set gfxmode=auto 
 +  load_video 
 +  insmod gfxterm 
 +  set locale_dir=$prefix/locale 
 +  set lang=en_US 
 +  insmod gettext 
 +fi 
 +terminal_output gfxterm 
 +if [ "${recordfail}" = 1 ] ; then 
 +  set timeout=30 
 +else 
 +  if [ x$feature_timeout_style = xy ] ; then 
 +    set timeout_style=menu 
 +    set timeout=5 
 +  # Fallback normal timeout code in case the timeout_style feature is 
 +  # unavailable. 
 +  else 
 +    set timeout=5 
 +  fi
 fi fi
 ### END /etc/grub.d/00_header ### ### END /etc/grub.d/00_header ###
 +
 +### BEGIN /etc/grub.d/05_debian_theme ###
 +insmod part_msdos
 +insmod ext2
 +set root='hd0,msdos1'
 +if [ x$feature_platform_search_hint = xy ]; then
 +  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e
 +else
 +  search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e
 +fi
 +insmod png
 +if background_image /usr/share/desktop-base/homeworld-theme/grub/grub-4x3.png; then
 +  set color_normal=white/black
 +  set color_highlight=black/white
 +else
 +  set menu_color_normal=cyan/blue
 +  set menu_color_highlight=white/blue
 +fi
 +### END /etc/grub.d/05_debian_theme ###
  
 ### BEGIN /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/10_linux ###
-menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' +function gfxmode 
- load_video +        set gfxpayload="${1}"
- set gfxpayload=keep +
- insmod gzio +
- insmod part_msdos +
- insmod xfs +
- set root='hd0,msdos1' +
- if [ x$feature_platform_search_hint = xy ]; then +
-   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309 +
- else +
-   search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 +
- fi +
- linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 +
- initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img+
 } }
-menuentry 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { +set linux_gfx_mode= 
- load_video +export linux_gfx_mode 
- set gfxpayload=keep +menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9887a74f-a680-4bde-8f04-db5ae9ea186e' { 
- insmod gzio +        load_video 
- insmod part_msdos +        insmod gzio 
- insmod xfs +        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi 
- set root='hd0,msdos1' +        insmod part_msdos 
- if [ x$feature_platform_search_hint = xy ]; then +        insmod ext2 
-   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309 +        set root='hd0,msdos1' 
- else +        if [ x$feature_platform_search_hint = xy ]; then 
-   search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 +          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e 
- fi +        else 
- linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 +          search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e 
- initrd16 /initramfs-3.10.0-123.el7.x86_64.img+        fi 
 +        echo    'Loading Linux 5.10.0-13-amd64 ...' 
 +        linux   /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro  quiet 
 +        echo    'Loading initial ramdisk ...' 
 +        initrd  /boot/initrd.img-5.10.0-13-amd64
 } }
-menuentry 'CentOS Linux, with Linux 0-rescue-a2feb9eb09b1488da0f23b99a66350f8' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-a2feb9eb09b1488da0f23b99a66350f8-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' { +submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-9887a74f-a680-4bde-8f04-db5ae9ea186e'
- load_video +        menuentry 'Debian GNU/Linux, with Linux 5.10.0-13-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.10.0-13-amd64-advanced-9887a74f-a680-4bde-8f04-db5ae9ea186e' { 
- insmod gzio +                load_video 
- insmod part_msdos +                insmod gzio 
- insmod xfs +                if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi 
- set root='hd0,msdos1' +                insmod part_msdos 
- if [ x$feature_platform_search_hint = xy ]; then +                insmod ext2 
-   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309 +                set root='hd0,msdos1' 
- else +                if [ x$feature_platform_search_hint = xy ]; then 
-   search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 +                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e 
- fi +                else 
- linux16 /vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet +                  search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e 
- initrd16 /initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img+                fi 
 +                echo    'Loading Linux 5.10.0-13-amd64 ...' 
 +                linux   /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro  quiet 
 +                echo    'Loading initial ramdisk ...' 
 +                initrd  /boot/initrd.img-5.10.0-13-amd64 
 +        } 
 +        menuentry 'Debian GNU/Linux, with Linux 5.10.0-13-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.10.0-13-amd64-recovery-9887a74f-a680-4bde-8f04-db5ae9ea186e'
 +                load_video 
 +                insmod gzio 
 +                if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi 
 +                insmod part_msdos 
 +                insmod ext2 
 +                set root='hd0,msdos1' 
 +                if [ x$feature_platform_search_hint = xy ]; then 
 +                  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e 
 +                else 
 +                  search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e 
 +                fi 
 +                echo    'Loading Linux 5.10.0-13-amd64 ...' 
 +                linux   /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro single  
 +                echo    'Loading initial ramdisk ...' 
 +                initrd  /boot/initrd.img-5.10.0-13-amd64 
 +        }
 } }
-if [ "x$default" = 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' ]; then default='Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64'; fi;+
 ### END /etc/grub.d/10_linux ### ### END /etc/grub.d/10_linux ###
  
 ### BEGIN /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_linux_xen ###
 +
 ### END /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ###
- 
-### BEGIN /etc/grub.d/20_ppc_terminfo ### 
-### END /etc/grub.d/20_ppc_terminfo ### 
  
 ### BEGIN /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/30_os-prober ###
 ### END /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ###
 +
 +### BEGIN /etc/grub.d/30_uefi-firmware ###
 +### END /etc/grub.d/30_uefi-firmware ###
  
 ### BEGIN /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/40_custom ###
Ligne 547: Ligne 602:
 | rootnoverify (hd0,1) | Ce paramètre n'existe plus sous GRUB 2. Les paramètres des systèmes d'exploitation non Linux sont définit avec le paramètre **root** | | rootnoverify (hd0,1) | Ce paramètre n'existe plus sous GRUB 2. Les paramètres des systèmes d'exploitation non Linux sont définit avec le paramètre **root** |
  
-Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande **grub2-mkconfig** sous RHEL/CentOS 7. La commande grub2-mkconfig prend en argument l'emplacement du fichier destination, par exemple :+Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande **update-grub** ou la commande **grub-mkconfig** sous Debian. La commande grub-mkconfig prend en argument l'emplacement du fichier destination, par exemple :
  
-  * grub2-mkconfig -o /boot/grub2/grub.cfg, ou +  * grub-mkconfig -o /boot/grub/grub.cfg 
-  * grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg+  * grub-mkconfig -o /boot/edi/EFI/debian/grub.cfg
  
-Lors de l'exécution de la commande **grub2-mkconfig** plusieurs fichiers sont lus :+Lors de l'exécution de la commande **grub-mkconfig**plusieurs fichiers sont lus :
  
 ===Le fichier /boot/grub2/device.map=== ===Le fichier /boot/grub2/device.map===
  
 <code> <code>
-[root@centos7 ~]# cat /boot/grub2/device.map +root@debian11:~# cat /boot/grub/device.map 
-this device map was generated by anaconda +cat: /boot/grub/device.map: No such file or directory 
-(hd0)      /dev/sda +root@debian11:~grub-mkdevicemap 
-(hd1)      /dev/sda+root@debian11:~# cat /boot/grub/device.map 
 +(hd0)   /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi2 
 +(hd1)   /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 
 +(hd2)   /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1 
 +(hd3)   /dev/disk/by-id/lvm-pv-uuid-1JO10Q-CM90-tKxI-OsM6-0vbe-3eDG-S10H6d 
 +(hd4)   /dev/disk/by-id/lvm-pv-uuid-GEkOIP-S7ce-8S1G-K0TX-ocxE-Ud6y-IY3fOZ 
 +(hd5)   /dev/disk/by-id/lvm-pv-uuid-J7UiEX-m983-j1fp-rU7x-TuCh-MFKh-s1O5M0
 </code> </code>
  
Ligne 568: Ligne 629:
  
 <code> <code>
-[root@centos7 ~]# cat /etc/default/grub+root@debian11:~# cat /etc/default/grub 
 +# If you change this file, run 'update-grub' afterwards to update 
 +# /boot/grub/grub.cfg. 
 +# For full documentation of the options in this file, see: 
 +#   info -f grub -n 'Simple configuration' 
 + 
 +GRUB_DEFAULT=0
 GRUB_TIMEOUT=5 GRUB_TIMEOUT=5
-GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" +GRUB_DISTRIBUTOR=`lsb_release -i -2> /dev/null || echo Debian` 
-GRUB_DEFAULT=saved +GRUB_CMDLINE_LINUX_DEFAULT="quiet
-GRUB_DISABLE_SUBMENU=true +GRUB_CMDLINE_LINUX=""
-GRUB_TERMINAL_OUTPUT="console+
-GRUB_CMDLINE_LINUX="vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet" +
-GRUB_DISABLE_RECOVERY="true" +
-</code>+
  
 +# Uncomment to enable BadRAM filtering, modify to suit your needs
 +# This works with Linux (no patch required) and with any kernel that obtains
 +# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
 +#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
 +
 +# Uncomment to disable graphical terminal (grub-pc only)
 +#GRUB_TERMINAL=console
 +
 +# The resolution used on graphical terminal
 +# note that you can use only modes which your graphic card supports via VBE
 +# you can see them in real GRUB with the command `vbeinfo'
 +#GRUB_GFXMODE=640x480
 +
 +# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
 +#GRUB_DISABLE_LINUX_UUID=true
 +
 +# Uncomment to disable generation of recovery mode menu entries
 +#GRUB_DISABLE_RECOVERY="true"
 +
 +# Uncomment to get a beep at grub start
 +#GRUB_INIT_TUNE="480 440 1"
 +</code>
  
-<WRAP center round important> +<WRAP center round important 60% 
-**Important** : Notez que toute modification de ce fichier nécessite l'exécution de la commande **grub2-mkconfig** sous RHEL/CentOS 7 pour que les modifications soient prises en compte.+**Important** : Notez que toute modification de ce fichier nécessite l'exécution de la commande **grub-mkconfig** pour que les modifications soient prises en compte.
 </WRAP> </WRAP>
  
-Dans ce fichier les directives sont :+Dans ce fichier les directives les plus importantes sont :
  
 ^  Directive  ^ Description ^ ^  Directive  ^ Description ^
Ligne 591: Ligne 676:
 | GRUB_CMDLINE_LINUX_DEFAULT | Paramètres passés au noyau lors d'un démarrage normal (Hors donc le mode secours) | | GRUB_CMDLINE_LINUX_DEFAULT | Paramètres passés au noyau lors d'un démarrage normal (Hors donc le mode secours) |
 | GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage | | GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage |
 +| GRUB_BADRAM | Permet de spécifier de la mémoire défaillante |
 | GRUB_TERMINAL | Si non commentée, cette directive désactive le démarrage graphique | | GRUB_TERMINAL | Si non commentée, cette directive désactive le démarrage graphique |
 | GRUB_GFXMODE | Indique la résolution utilisée lors d'un démarrage graphique | | GRUB_GFXMODE | Indique la résolution utilisée lors d'un démarrage graphique |
Ligne 596: Ligne 682:
 | GRUB_DISABLE_LINUX_RECOVERY | Si **true**, cette directive empêche la génération des entrées en mode **recovery** | | GRUB_DISABLE_LINUX_RECOVERY | Si **true**, cette directive empêche la génération des entrées en mode **recovery** |
 | GRUB_INIT_TUNE | Permet d'obtenir un beep au démarrage de GRUB 2 | | GRUB_INIT_TUNE | Permet d'obtenir un beep au démarrage de GRUB 2 |
-| GRUB_BADRAM | Permet de spécifier de la mémoire défaillante | 
  
 ===Les fichiers du répertoire /etc/grub.d=== ===Les fichiers du répertoire /etc/grub.d===
Ligne 603: Ligne 688:
  
 <code> <code>
-[root@centos7 ~]# ls -l /etc/grub.d +root@debian11:~# ls -l /etc/grub.d 
-total 68 +total 80 
--rwxr-xr-x1 root root  8702 Mar 26 09:27 00_header +-rwxr-xr-x 1 root root 10046 Jul 11  2021 00_header 
--rwxr-xr-x1 root root   992 Oct 17  2014 00_tuned +-rwxr-xr-x 1 root root  6260 Jul 11  2021 05_debian_theme 
--rwxr-xr-x1 root root 10114 Mar 26 09:27 10_linux +-rwxr-xr-x 1 root root 13664 Jul 11  2021 10_linux 
--rwxr-xr-x1 root root 10275 Mar 26 09:27 20_linux_xen +-rwxr-xr-x 1 root root 13726 Jul 11  2021 20_linux_xen 
--rwxr-xr-x1 root root  2559 Mar 26 09:27 20_ppc_terminfo +-rwxr-xr-x 1 root root 12059 Jul 11  2021 30_os-prober 
--rwxr-xr-x1 root root 11169 Mar 26 09:27 30_os-prober +-rwxr-xr-x 1 root root  1416 Jul 11  2021 30_uefi-firmware 
--rwxr-xr-x1 root root   214 Mar 26 09:27 40_custom +-rwxr-xr-x 1 root root   214 Jul 11  2021 40_custom 
--rwxr-xr-x1 root root   216 Mar 26 09:27 41_custom +-rwxr-xr-x 1 root root   216 Jul 11  2021 41_custom 
--rw-r--r--1 root root   483 Mar 26 09:27 README+-rw-r--r-- 1 root root   483 Jul 11  2021 README
 </code> </code>
  
Ligne 622: Ligne 707:
   * **Les fichiers /etc/grub.d/40_custom et /etc/grub.d/41_custom**,   * **Les fichiers /etc/grub.d/40_custom et /etc/grub.d/41_custom**,
     * Ces deux fichiers sont fournis en tant que modèles à personnaliser.     * Ces deux fichiers sont fournis en tant que modèles à personnaliser.
- 
-===Configurer l'Authentification=== 
- 
-==RHEL/CentOS < 7.2== 
- 
-Pour configurer l'authentification sous GRUB 2, il faut créer le fichier **/etc/grub.d/01_users** : 
- 
-<code> 
-[root@centos7 ~]# touch /etc/grub.d/01_users  
-[root@centos7 ~]# chmod 755 /etc/grub.d/01_users  
-</code> 
- 
-Créez deux mots de passe hashés au format **[[https://fr.wikipedia.org/wiki/PBKDF2|PBKDF2]]** en utilisant la commande **grub2-mkpasswd-pbkdf2** sous RHEL/CentOS : 
- 
-<code> 
-[root@centos7 ~]# grub2-mkpasswd-pbkdf2 
-Enter password: pass123 
-Reenter password: pass123 
-PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD 
-</code> 
- 
-Editez le fichier **/etc/grub.d/01_users** ainsi : 
- 
-<file txt /etc/grub.d/01_users> 
-#!/bin/sh -e 
-cat <<EOF 
-set superusers="root" 
-password_pbkdf2 root 
-grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD 
-EOF 
-</file> 
- 
-Il est aussi possible d'utiliser des mots de passe non cryptés. Modifiez donc le fichier **/etc/grub.d/01_users** ainsi : 
- 
-<file txt /etc/grub.d/01_users> 
-#!/bin/sh -e 
-cat <<EOF 
-set superusers="root" 
-password root pass123 
-EOF 
-</file> 
- 
-Sous RHEL/CentOS, lancez la commande **grub2-mkconfig -o /boot/grub2/grub.cfg** : 
- 
-<code> 
-[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
-Generating grub configuration file ... 
-Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 
-Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img 
-Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 
-Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img 
-Found linux image: /boot/vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 
-Found initrd image: /boot/initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img 
-done 
-</code> 
- 
-<WRAP center round todo> 
-**A faire** : Redémarrez votre VM. Constatez que GRUB 2 demande un nom d'utilisateur ainsi qu'un mot de passe. Attention, le clavier est en QWERTY ( pass123 = pqss&é“ ). 
-</WRAP> 
- 
-==RHEL/CentOS >= 7.2== 
- 
-Depuis la version 7.2 de RHEL/centOS le fichier **/etc/grub.d/01_users** existe déjà : 
- 
-<code> 
-[root@centos7 ~]# cat /etc/grub.d/01_users  
-#!/bin/sh -e 
-cat << EOF 
-if [ -f \${prefix}/user.cfg ]; then 
-  source \${prefix}/user.cfg 
-  if [ -n "\${GRUB2_PASSWORD}" ]; then 
-    set superusers="root" 
-    export superusers 
-    password_pbkdf2 root \${GRUB2_PASSWORD} 
-  fi 
-fi 
-EOF 
-</code> 
- 
-Ce script est évidement présent dans le fichier **grub.cfg** : 
- 
-<code> 
-### BEGIN /etc/grub.d/01_users ### 
-if [ -f ${prefix}/user.cfg ]; then 
-  source ${prefix}/user.cfg 
-  if [ -n ${GRUB2_PASSWORD} ]; then 
-    set superusers="root" 
-    export superusers 
-    password_pbkdf2 root ${GRUB2_PASSWORD} 
-  fi 
-fi 
-### END /etc/grub.d/01_users ### 
-</code> 
- 
-Ce script : 
- 
-  * teste si le fichier **/boot/grub2/user.cfg** existe puis si c'est le cas, 
-  * teste si la variable $GRUB2_PASSWORD est fixée puis si c'est le cas, 
-  * assigne le mot de passe à root. 
- 
-Pour créer le contenu du fichier **/boot/grub2/user.cfg**, il convient d'utiliser la commande **grub2-setpassword** : 
- 
-<code> 
-[root@centos7 ~]# grub2-setpassword 
-Enter password: pass123 
-Confirm password: pass123 
-</code> 
- 
-Consultez maintenant le fichier **/boot/grub2/user.cfg** : 
- 
-<code> 
-[root@centos7 ~]# cat /boot/grub2/user.cfg 
-GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.3DD268A626FC781A0693D381A5F1BBDE6C834D1D904F023AED8CEF2985304FEC9F0C1C8B975156F5DF534F4B10BCCDC5C187B0C12F55E970A244D9EF2EF962DD.9BB2011598B8E5EFD9A464ED96C0FECB8DCD8FD6942E5114E035AD8A9E2DCFF32A9DC1C222B4226A462B32E7B6D80247F96D79133F18F6524544984837EF4D06 
-</code> 
- 
-<WRAP center round todo> 
-**A faire** : Redémarrez votre VM. Appuyez sur la touche **e** au début du processus de démarrage. Constatez que GRUB 2 demande un nom d'utilisateur ainsi qu'un mot de passe. Attention, le clavier est en QWERTY ( pass123 = pqss&é“ ). Notez qu'à ce stade le mot de passe ne protège que l'édition des entrées de GRUB2. 
-</WRAP> 
- 
-Pour pouvoir protéger le démarrage du système, il convient d'éditer le fichier **grub.cfg** en supprimant la directive **--unrestricted** de la ligne **menuentry** : 
- 
-<code> 
-[root@centos7 ~]# cat /boot/grub2/grub.cfg 
-... 
-### BEGIN /etc/grub.d/10_linux ### 
-menuentry 'CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-e65fe7da-cda8-4f5a-a827-1b5cabe94bed' { 
-        load_video 
-        set gfxpayload=keep 
-        insmod gzio 
-        insmod part_msdos 
-        insmod xfs 
-        set root='hd0,msdos1' 
-        if [ x$feature_platform_search_hint = xy ]; then 
-          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  2d947276-66e8-41f4-8475-b64b67d7a249 
-        else 
-          search --no-floppy --fs-uuid --set=root 2d947276-66e8-41f4-8475-b64b67d7a249 
-        fi 
-        linux16 /vmlinuz-3.10.0-693.21.1.el7.x86_64 root=UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed ro rhgb quiet LANG=en_GB.UTF-8 
-        initrd16 /initramfs-3.10.0-693.21.1.el7.x86_64.img 
-} 
-... 
-</code> 
- 
-<code> 
-[root@centos7 ~]# vi /boot/grub2/grub.cfg 
-... 
-### BEGIN /etc/grub.d/10_linux ### 
-menuentry 'CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-e65fe7da-cda8-4f5a-a827-1b5cabe94bed' { 
-        load_video 
-        set gfxpayload=keep 
-        insmod gzio 
-        insmod part_msdos 
-        insmod xfs 
-        set root='hd0,msdos1' 
-        if [ x$feature_platform_search_hint = xy ]; then 
-          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  2d947276-66e8-41f4-8475-b64b67d7a249 
-        else 
-          search --no-floppy --fs-uuid --set=root 2d947276-66e8-41f4-8475-b64b67d7a249 
-        fi 
-        linux16 /vmlinuz-3.10.0-693.21.1.el7.x86_64 root=UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed ro rhgb quiet LANG=en_GB.UTF-8 
-        initrd16 /initramfs-3.10.0-693.21.1.el7.x86_64.img 
-} 
-... 
-</code> 
- 
-<WRAP center round todo> 
-**A faire** : Redémarrez votre VM. Constatez que GRUB 2 demande un nom d'utilisateur ainsi qu'un mot de passe. Attention, le clavier est en QWERTY ( pass123 = pqss&é“ ). Notez que cette modification n'est pas permenante.  
-</WRAP> 
- 
  
 ===Modifier la Configuration de GRUB 2 en Ligne de Commande=== ===Modifier la Configuration de GRUB 2 en Ligne de Commande===
Ligne 806: Ligne 722:
   * **echap** : abandonner les modifications et retourner à l'interface menu de GRUB 2.   * **echap** : abandonner les modifications et retourner à l'interface menu de GRUB 2.
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Certaines distributions, telle qu'Ubuntu, cache le menu de GRUB 2 derrière une interface graphique. Afin de voir ce menu, il convient d'appuyer sur la touche **Shift** pendant que la machine démarre. **Important** : Certaines distributions, telle qu'Ubuntu, cache le menu de GRUB 2 derrière une interface graphique. Afin de voir ce menu, il convient d'appuyer sur la touche **Shift** pendant que la machine démarre.
 </WRAP> </WRAP>
Ligne 848: Ligne 764:
 Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, qui peut être chargé sur un disque **ou** une clef USB. Le fichier isodhpfx.bin est créé avec le programme **xorriso**. Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, qui peut être chargé sur un disque **ou** une clef USB. Le fichier isodhpfx.bin est créé avec le programme **xorriso**.
  
- +=====Initramfs sous RHEL/CentOS 6=====
-====Initramfs sous RHEL/CentOS 6====+
  
 Un fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système. Un fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système.
Ligne 925: Ligne 840:
 </code> </code>
  
-<WRAP center round todo>+<WRAP center round todo 60%>
 **A faire** : Utilisez le manuel de la commande **cpio** pour comprendre les options utilisées. **A faire** : Utilisez le manuel de la commande **cpio** pour comprendre les options utilisées.
 </WRAP> </WRAP>
Ligne 966: Ligne 881:
 </code> </code>
  
-<WRAP center round todo>+<WRAP center round todo 60%>
 **A faire** : Passez en revue le contenu du script. **A faire** : Passez en revue le contenu du script.
 </WRAP> </WRAP>
Ligne 1081: Ligne 996:
  
  
-<WRAP center round todo>+<WRAP center round todo 60%>
 **A faire** : **Re-démarrez votre machine pour tester votre configuration.** **A faire** : **Re-démarrez votre machine pour tester votre configuration.**
 </WRAP> </WRAP>
  
-====Initramfs sous RHEL/CentOS 7====+=====Initramfs sous Debian 11=====
  
-Le fichier Initramfs //%%INITial Ram File System%%// est une archive au format cpio compressé :+Le fichier Initramfs //%%INITial Ram File System%%// est une image d'un système minimal initialisée au démarrage du système.
  
-<code> +====LAB #1 - Travailler avec Initramfs
-[root@centos7 ~]cp /boot/initramfs-3.10.0-514.16.1.el7.x86_64.img /tmp/custom +
-[root@centos7 ~]# cd /tmp +
-[root@centos7 tmp]# ls +
-custom  systemd-private-be6ac69163a0437aa9a0b0cb2f8514e6-chronyd.service-rOpG2C  systemd-private-be6ac69163a0437aa9a0b0cb2f8514e6-cups.service-yzrHum +
-[root@centos7 tmp]# mv custom custom.gz +
-[root@centos7 tmp]# gunzip custom.gz  +
-[root@centos7 tmp]# mkdir initramfs +
-[root@centos7 tmp]# cd initramfs +
-[root@centos7 initramfs]# cpio -cid -I ../custom +
-113591 blocks +
-[root@centos7 initramfs]# ls +
-bin  dev  etc  init  lib  lib64  proc  root  run  sbin  shutdown  sys  sysroot  tmp  usr  var +
-[root@centos7 initramfs]# ls -l +
-total 4 +
-lrwxrwxrwx.  1 root root    7 Dec  4 11:00 bin -> usr/bin +
-drwxr-xr-x.  2 root root  100 Dec  4 11:00 dev +
-drwxr-xr-x. 11 root root  520 Dec  4 11:00 etc +
-lrwxrwxrwx.  1 root root   23 Dec  4 11:00 init -> usr/lib/systemd/systemd +
-lrwxrwxrwx.  1 root root    7 Dec  4 11:00 lib -> usr/lib +
-lrwxrwxrwx.  1 root root    9 Dec  4 11:00 lib64 -> usr/lib64 +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 proc +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 root +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 run +
-lrwxrwxrwx.  1 root root    8 Dec  4 11:00 sbin -> usr/sbin +
--rwxr-xr-x.  1 root root 3117 Dec  4 11:00 shutdown +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 sys +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 sysroot +
-drwxr-xr-x.  2 root root   40 Dec  4 11:00 tmp +
-drwxr-xr-x.  7 root root  140 Dec  4 11:00 usr +
-drwxr-xr-x.  2 root root   80 Dec  4 11:00 var +
-</code>+
  
-===Examiner l'image existante===+===1.1 - Examiner l'image existante===
  
-Pour examiner une image initramfs archivée, il convient d'utiliser la commande **lsinitrd** :+Pour examiner une image initramfs, il convient d'abord de la copier vers /tmp et de la décompresser :
  
 <code> <code>
-[root@centos7 initramfs]cd .+root@debian11:~cp /boot/initrd.img-5.10.0-13-amd64 /tmp/custom.gz 
-[root@centos7 tmp]# lsinitrd custom | more +root@debian11:~# gunzip /tmp/custom.gz 
-Image: custom: 56M +
-======================================================================== +
-Version: dracut-033-502.el7_4.+
- +
-Arguments: -f +
- +
-dracut modules: +
-bash +
-nss-softokn +
-i18n +
-network +
-ifcfg +
-drm +
-plymouth +
-kernel-modules +
-qemu +
-resume +
-rootfs-block +
-terminfo +
-udev-rules +
-biosdevname +
-systemd +
-usrmount +
-base +
-fs-lib +
-shutdown +
-======================================================================== +
-drwxr-xr-x  12 root     root            Apr 23  2018 . +
-crw-r--r--   1 root     root       5,   1 Apr 23  2018 dev/console +
-crw-r--r--   1 root     root       1,  11 Apr 23  2018 dev/kmsg +
-crw-r--r--   1 root     root       1,   3 Apr 23  2018 dev/null +
-lrwxrwxrwx   1 root     root            7 Apr 23  2018 bin -> usr/bin +
-drwxr-xr-x   2 root     root            0 Apr 23  2018 dev +
-drwxr-xr-x  11 root     root            0 Apr 23  2018 etc +
-drwxr-xr-x   2 root     root            0 Apr 23  2018 etc/cmdline.d +
-drwxr-xr-x   root     root            0 Apr 23  2018 etc/conf.d +
--rw-r--r--   1 root     root          124 Apr 23  2018 etc/conf.d/systemd.conf +
--rw-r--r--   1 root     root          248 Jan  5  2018 etc/dhclient.conf +
--rw-r--r--   1 root     root            0 Apr 23  2018 etc/fstab.empty +
---More--+
 </code> </code>
  
-Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste : +Ensuite il convient d'extraire l'image grâce à la commande **cpio** : 
- +
-===Le script init=== +
- +
-Le script **init** est lancé lors du chargement de l'image. RHEL/CentOS 7 utilise le système de démarrage **systemd**. Pour cette raison le script init sous RHEL/CentOS 7 est un lien symbolique vers **/usr/lib/systemd/systemd** :+
  
 <code> <code>
-[root@centos7 tmp]lsinitrd custom | grep init +root@debian11:~# cd /tmp 
-... +root@debian11:/tmp# mkdir initrd 
-lrwxrwxrwx. root root   23 Dec  4 11:00 init -> usr/lib/systemd/systemd+root@debian11:/tmp# cd initrd 
 +root@debian11:/tmp/initrd# cpio -idvB < ../custom
 ... ...
 +var
 +var/cache
 +var/cache/fontconfig
 +var/cache/fontconfig/2cf0bf67-ac23-47f4-9d76-913901374fea-le64.cache-7
 +var/cache/fontconfig/42771ecd-ce02-464a-8263-bedea4e63b34-le64.cache-7
 +var/cache/fontconfig/CACHEDIR.TAG
 +var/cache/fontconfig/ce5f225d-fe60-43b7-ad9d-497d8ccce03f-le64.cache-7
 +var/cache/fontconfig/f8222393-3a24-44e9-bff6-c3f977041ad4-le64.cache-7
 +31991 blocks
 </code> </code>
  
-===Consulter le contenu d'un fichier dans initramfs=== +Installez maintenant le paquet **tree** : 
- +
-Pour consulter le contenu d'un fichier inclus dans l'initramfs, il convient d'utiliser la commande **lsinitrd** de la manière suivante :+
  
 <code> <code>
-[root@centos7 tmp]lsinitrd /boot/initramfs-$(uname -r).img  /etc/ld.so.conf +root@debian11:/tmp/initrdapt-get -y install tree
-include ld.so.conf.d/*.conf+
 </code> </code>
  
-===La Commande dracut=== +Utilisez maintenant la commande **tree** pour examiner le contenu de l'image :
- +
-La commande **dracut** permet de créer facilement une image initramfs. Les options de la commande sont :+
  
 <code> <code>
-[root@centos7 tmp]dracut --help +root@debian11:/tmp/initrdtree | more 
-Usage: /sbin/dracut [OPTION]... [<initramfs> [<kernel-version>]]+
 +├── bin -> usr/bin 
 +├── conf 
 +│   ├── arch.conf 
 +│   ├── conf.d 
 +│   │   └── resume 
 +│   └── initramfs.conf 
 +├── cryptroot 
 +│   └── crypttab 
 +├── etc 
 +│   ├── console-setup 
 +│   │   ├── cached_UTF-8_del.kmap 
 +│   │   └── null 
 +│   ├── default 
 +│   │   └── keyboard 
 +│   ├── fonts 
 +│   │   ├── conf.
 +│   │   │   └── 60-latin.conf 
 +│   │   └── fonts.conf 
 +│   ├── fstab 
 +│   ├── ld.so.cache 
 +│   ├── ld.so.conf 
 +│   ├── ld.so.conf.d 
 +│   │   ├── libc.conf 
 +│   │   └── x86_64-linux-gnu.conf 
 +│   ├── lvm 
 +│   │   ├── archive 
 +│   │   │   ├── vg0_00000-267942700.vg 
 +│   │   │   ├── vg0_00001-854434220.vg 
 +│   │   │   ├── vg0_00002-520659205.vg 
 +│   │   │   ├── vg0_00003-1606608177.vg 
 +│   │   │   ├── vg0_00004-458787361.vg 
 +│   │   │   ├── vg0_00005-1786773709.vg 
 +│   │   │   ├── vg0_00006-196117920.vg 
 +│   │   │   ├── vg0_00007-2024993792.vg 
 +│   │   │   ├── vg0_00008-297779072.vg 
 +│   │   │   ├── vg0_00009-1557237202.vg 
 +│   │   │   ├── vg0_00010-550024633.vg 
 +│   │   │   ├── vg0_00011-155655591.vg 
 +│   │   │   └── vg0_00012-1101644815.vg 
 +│   │   ├── backup 
 +│   │   │   └── vg0 
 +│   │   ├── lvm.conf 
 +│   │   ├── lvmlocal.conf 
 +│   │   └── profile 
 +│   │       ├── cache-mq.profile 
 +│   │       ├── cache-smq.profile 
 +│   │       ├── command_profile_template.profile 
 +│   │       ├── lvmdbusd.profile 
 +│   │       ├── metadata_profile_template.profile 
 +│   │       ├── thin-generic.profile 
 +│   │       ├── thin-performance.profile 
 +│   │       └── vdo-small.profile 
 +│   ├── modprobe.d 
 +│   ├── motd 
 +│   ├── mtab -/proc/mounts 
 +│   ├── nsswitch.conf 
 +│   ├── os-release 
 +--More-- 
 +[q] 
 +</code>
  
-Version033-463.el7+Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste :
  
-Creates initial ramdisk images for preloading modules+<code> 
 +root@debian11:/tmp/initrd# ls -l 
 +total 36 
 +lrwxrwxrwx  1 root root    7 Apr 30 11:02 bin -> usr/bin 
 +drwxr-xr-x  3 root root 4096 Apr 30 11:02 conf 
 +drwxr-xr-x  2 root root 4096 Apr 30 11:02 cryptroot 
 +drwxr-xr-x 10 root root 4096 Apr 30 11:02 etc 
 +-rwxr-xr-x  1 root root 6301 Apr 30 11:02 init 
 +lrwxrwxrwx  1 root root    7 Apr 30 11:02 lib -> usr/lib 
 +lrwxrwxrwx  1 root root    9 Apr 30 11:02 lib32 -> usr/lib32 
 +lrwxrwxrwx  1 root root    9 Apr 30 11:02 lib64 -> usr/lib64 
 +lrwxrwxrwx  1 root root   10 Apr 30 11:02 libx32 -> usr/libx32 
 +drwxr-xr-x  2 root root 4096 Apr 30 11:02 run 
 +lrwxrwxrwx  1 root root    8 Apr 30 11:02 sbin -> usr/sbin 
 +drwxr-xr-x 10 root root 4096 Apr 30 11:02 scripts 
 +drwxr-xr-x 10 root root 4096 Apr 30 11:02 usr 
 +drwxr-xr-x  3 root root 4096 Apr 30 11:02 var 
 +</code>
  
-  --kver [VERSION]      Set kernel version to [VERSION]. +Le script **init** est lancé lors du chargement de l'image :
-  -f, --force           Overwrite existing initramfs file. +
-  -a, --add [LIST]      Add a space-separated list of dracut modules. +
-  --rebuild         Append arguments to those of existing image and rebuild +
-  -m, --modules [LIST]  Specify a space-separated list of dracut modules to +
-                         call when building the initramfs. Modules are located +
-                         in /usr/lib/dracut/modules.d. +
-  -o, --omit [LIST]     Omit a space-separated list of dracut modules. +
-  --force-add [LIST]    Force to add a space-separated list of dracut modules +
-                         to the default set of modules, when -H is specified. +
-  -d, --drivers [LIST]  Specify a space-separated list of kernel modules to +
-                         exclusively include in the initramfs. +
-  --add-drivers [LIST]  Specify a space-separated list of kernel +
-                         modules to add to the initramfs. +
-  --omit-drivers [LIST] Specify a space-separated list of kernel +
-                         modules not to add to the initramfs. +
-  --filesystems [LIST]  Specify a space-separated list of kernel filesystem +
-                         modules to exclusively include in the generic +
-                         initramfs. +
-  -k, --kmoddir [DIR]   Specify the directory, where to look for kernel +
-                         modules +
-  --fwdir [DIR]         Specify additional directories, where to look for +
-                         firmwares, separated by : +
-  --kernel-only         Only install kernel drivers and firmware files +
-  --no-kernel           Do not install kernel drivers and firmware files +
-  --print-cmdline       Print the kernel command line for the given disk layout +
-  --early-microcode     Combine early microcode with ramdisk +
-  --no-early-microcode  Do not combine early microcode with ramdisk +
-  --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters +
-  --strip               Strip binaries in the initramfs +
-  --nostrip             Do not strip binaries in the initramfs +
-  --prelink             Prelink binaries in the initramfs +
-  --noprelink           Do not prelink binaries in the initramfs +
-  --hardlink            Hardlink files in the initramfs +
-  --nohardlink          Do not hardlink files in the initramfs +
-  --prefix [DIR]        Prefix initramfs files with [DIR] +
-  --noprefix            Do not prefix initramfs files +
-  --mdadmconf           Include local /etc/mdadm.conf +
-  --nomdadmconf         Do not include local /etc/mdadm.conf +
-  --lvmconf             Include local /etc/lvm/lvm.conf +
-  --nolvmconf           Do not include local /etc/lvm/lvm.conf +
-  --fscks [LIST]        Add a space-separated list of fsck helpers. +
-  --nofscks             Inhibit installation of any fsck helpers. +
-  --ro-mnt              Mount / and /usr read-only by default. +
-  -h, --help            This message +
-  --debug               Output debug information of the build process +
-  --profile             Output profile information of the build process +
-  -L, --stdlog [0-6]    Specify logging level (to standard error) +
-                         0 - suppress any messages +
-                         1 - only fatal errors +
-                         2 - all errors +
-                         3 - warnings +
-                         4 - info +
-                         5 - debug info (here starts lots of output) +
-                         6 - trace info (and even more) +
-  -v, --verbose         Increase verbosity level +
-  -q, --quiet           Decrease verbosity level +
-  -c, --conf [FILE]     Specify configuration file to use. +
-                         Default: /etc/dracut.conf +
-  --confdir [DIR]       Specify configuration directory to use *.conf files +
-                         from. Default: /etc/dracut.conf.d +
-  --tmpdir [DIR]        Temporary directory to be used instead of default +
-                         /var/tmp. +
-  -l, --local           Local mode. Use modules from the current working +
-                         directory instead of the system-wide installed in +
-                         /usr/lib/dracut/modules.d. +
-                         Useful when running dracut from a git checkout. +
-  -H, --hostonly        Host-Only mode: Install only what is needed for +
-                        booting the local host instead of a generic host. +
-  -N, --no-hostonly     Disables Host-Only mode +
-  --hostonly-cmdline    Store kernel command line arguments needed +
-                        in the initramfs +
-  --no-hostonly-cmdline Do not store kernel command line arguments needed +
-                        in the initramfs +
-  --hostonly-i18n       Install only needed keyboard and font files according +
-                        to the host configuration (default). +
-  --no-hostonly-i18n    Install all keyboard and font files available. +
-  --persistent-policy [POLICY] +
-                        Use [POLICY] to address disks and partitions. +
-                        POLICY can be any directory name found in /dev/disk. +
-                        E.g. "by-uuid", "by-label" +
-  --fstab               Use /etc/fstab to determine the root device. +
-  --add-fstab [FILE]    Add file to the initramfs fstab +
-  --mount "[DEV] [MP] [FSTYPE] [FSOPTS]" +
-                        Mount device [DEV] on mountpoint [MP] with filesystem +
-                        [FSTYPE] and options [FSOPTS] in the initramfs +
-  --add-device "[DEV]"  Bring up [DEV] in initramfs +
-  -i, --include [SOURCE] [TARGET] +
-                        Include the files in the SOURCE directory into the +
-                         Target directory in the final initramfs. +
-                        If SOURCE is a file, it will be installed to TARGET +
-                         in the final initramfs. +
-  -I, --install [LIST]  Install the space separated list of files into the +
-                         initramfs. +
-  --install-optional [LIST]  Install the space separated list of files into the +
-                         initramfs, if they exist. +
-  --gzip                Compress the generated initramfs using gzip. +
-                         This will be done by default, unless another +
-                         compression option or --no-compress is passed. +
-  --bzip2               Compress the generated initramfs using bzip2. +
-                         Make sure your kernel has bzip2 decompression support +
-                         compiled in, otherwise you will not be able to boot. +
-  --lzma                Compress the generated initramfs using lzma. +
-                         Make sure your kernel has lzma support compiled in, +
-                         otherwise you will not be able to boot. +
-  --xz                  Compress the generated initramfs using xz. +
-                         Make sure that your kernel has xz support compiled +
-                         in, otherwise you will not be able to boot. +
-  --lzo                  Compress the generated initramfs using lzop. +
-                         Make sure that your kernel has lzo support compiled +
-                         in, otherwise you will not be able to boot. +
-  --lz4                  Compress the generated initramfs using lz4. +
-                         Make sure that your kernel has lz4 support compiled +
-                         in, otherwise you will not be able to boot. +
-  --compress [COMPRESSION] Compress the generated initramfs with the +
-                         passed compression program.  Make sure your kernel +
-                         knows how to decompress the generated initramfs, +
-                         otherwise you will not be able to boot. +
-  --no-compress         Do not compress the generated initramfs.  This will +
-                         override any other compression options. +
-  --list-modules        List all available dracut modules. +
-  -M, --show-modules    Print included module's name to standard output during +
-                         build. +
-  --keep                Keep the temporary initramfs for debugging purposes +
-  --printsize           Print out the module install size +
-  --sshkey [SSHKEY]     Add ssh key to initramfs (use with ssh-client module) +
-  --logfile [FILE]      Logfile to use (overrides configuration setting)+
  
-If [LIST] has multiple arguments, then you have to put these in quotes.+<code> 
 +root@debian11:/tmp/initrd# more init 
 +#!/bin/sh
  
-For example:+# Default PATH differs between shells, and is not automatically exported 
 +# by klibc dash.  Make it consistent. 
 +export PATH=/sbin:/usr/sbin:/bin:/usr/bin
  
-    # dracut --add-drivers "module1 module2"  ...+-d /dev ] || mkdir -m 0755 /dev 
 +-d /root ] || mkdir -m 0700 /root 
 +[ -d /sys ] || mkdir /sys 
 +[ -d /proc ] || mkdir /proc 
 +[ -d /tmp ] || mkdir /tmp 
 +mkdir -p /var/lock 
 +mount -t sysfs -o nodev,noexec,nosuid sysfs /sys 
 +mount -t proc -o nodev,noexec,nosuid proc /proc
  
-</code>+# shellcheck disable=SC2013 
 +for x in $(cat /proc/cmdline); do 
 +        case $x in 
 +        initramfs.clear) 
 +                clear 
 +                ;; 
 +        quiet) 
 +                quiet=y 
 +                ;; 
 +        esac 
 +done
  
-Le fichier de configuration de dracut est **/etc/dracut.conf** :+if [ "$quiet" != "y" ]; then 
 +        quiet=n 
 +        echo "Loading, please wait..." 
 +fi 
 +export quiet
  
-<file> +Note that this only becomes /dev on the real filesystem if udev's scripts 
-PUT YOUR CONFIG HERE OR IN separate files named *.conf +are used; which they will be, but it's worth pointing out 
-in /etc/dracut.conf.d +mount -t devtmpfs -o nosuid,mode=0755 udev /dev 
-# SEE man dracut.conf(5)+mkdir /dev/pts 
 +mount -t devpts -o noexec,nosuid,gid=5,mode=0620 devpts /dev/pts || true
  
-Sample dracut config file+Export the dpkg architecture 
 +export DPKG_ARCH= 
 +. /conf/arch.conf
  
-#logfile=/var/log/dracut.log +Set modprobe env 
-#fileloglvl=6+export MODPROBE_OPTIONS="-qb"
  
-Exact list of dracut modules to use.  Modules not listed here are not going +Export relevant variables 
-# to be included.  If you only want to add some optional modules use +export ROOT= 
-# add_dracutmodules option instead. +export ROOTDELAY= 
-#dracutmodules+=""+export ROOTFLAGS= 
 +export ROOTFSTYPE= 
 +export IP= 
 +export DEVICE= 
 +export BOOT= 
 +export BOOTIF= 
 +export UBIMTD= 
 +export break= 
 +export init=/sbin/init 
 +--More--(19%) 
 +</code>
  
-# dracut modules to omit +<WRAP center round todo 60%> 
-#omit_dracutmodules+=""+**A faire** : Passez en revue le contenu du script. 
 +</WRAP>
  
-# dracut modules to add to the default +===1.2 - La commande mkinitramfs===
-#add_dracutmodules+=""+
  
-# additional kernel modules to the default +La commande **mkinitramfs** permet de créer facilement une image initramfs. Les options de la commande sont :
-add_drivers+="ehci-hcd ohci-hcd usb-storage scsi_mod sd_mod"+
  
-# list of kernel filesystem modules to be included in the generic initramfs +<code> 
-#filesystems+=""+root@debian11:~mkinitramfs --help
  
-# build initrd only to boot current hardware +Usage: mkinitramfs [option]... -o outfile [version]
-#hostonly="yes" +
-#+
  
-# install local /etc/mdadm.conf +Options: 
-#mdadmconf="no"+  -c compress   Override COMPRESS setting in initramfs.conf. 
 +  -d confdir    Specify an alternative configuration directory. 
 +  -k            Keep temporary directory used to make the image. 
 +  -o outfile    Write to outfile. 
 +  -r root       Override ROOT setting in initramfs.conf.
  
-# install local /etc/lvm/lvm.conf +See mkinitramfs(8) for further details
-#lvmconf="no"+</code>
  
-# A list of fsck tools to install. If it's not specified, module's hardcoded +Le fichier de configuration de mkinitramfs est **/etc/initramfs-tools/modules**Editez ce fichier pour spécifier des modules noyau supplémentaires à inclure dans le fichier image générée :
-# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check +
-# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is +
-# opportunistic, so non-existing tools are just ignored. +
-#fscks="" +
- +
-# inhibit installation of any fsck tools +
-#nofscks="yes" +
- +
-# mount / and /usr read-only by default +
-#ro_mnt="no" +
- +
-# set the directory for temporary files +
-# default: /var/tmp +
-#tmpdir=/tmp +
-</file> +
- +
-Exécutez maintenant la commande suivante afin de générer le fichier **initramfs** :+
  
 <code> <code>
-[root@centos7 tmp]dracut -v initramfs +root@debian11:/tmp/initrdvi /etc/initramfs-tools/modules 
-Executing: /sbin/dracut -initramfs +root@debian11:/tmp/initrd# cat /etc/initramfs-tools/modules 
-dracut module 'busybox' will not be installed, because command 'busybox' could not be found! +# List of modules that you want to include in your initramfs. 
-dracut module 'busybox' will not be installed, because command 'busybox' could not be found! +# They will be loaded at boot time in the order below. 
-*** Including modulebash *** +# 
-*** Including module: nss-softokn *** +# Syntax module_name [args ...] 
-*** Including module: i18n *** +
-*** Including modulenetwork *** +# You must run update-initramfs(8) to effect this change. 
-*** Including module: ifcfg *** +# 
-*** Including module: drm *** +# Examples
-*** Including module: plymouth *** +# 
-*** Including module: kernel-modules *** +# raid1 
-*** Including module: qemu *** +# sd_mod 
-*** Including module: resume *** +usbcore 
-*** Including module: rootfs-block *** +uhci 
-*** Including module: terminfo *** +ehci-hcd 
-*** Including module: udev-rules *** +usb-ohci 
-Skipping udev rule: 91-permissions.rules +usb-uhci 
-*** Including module: biosdevname *** +usb-storage 
-*** Including module: systemd *** +scsi_mod 
-*** Including module: usrmount *** +sd_mod
-*** Including module: base *** +
-*** Including module: fs-lib *** +
-*** Including module: shutdown *** +
-*** Including modules done *** +
-*** Installing kernel module dependencies and firmware *** +
-*** Installing kernel module dependencies and firmware done *** +
-*** Resolving executable dependencies *** +
-*** Resolving executable dependencies done*** +
-*** Hardlinking files *** +
-*** Hardlinking files done *** +
-*** Stripping files *** +
-*** Stripping files done *** +
-*** Generating early-microcode cpio image contents *** +
-*** Constructing GenuineIntel.bin **** +
-*** Store current command line parameters *** +
-*** Creating image file *** +
-*** Creating microcode section *** +
-*** Created microcode section *** +
-*** Creating image file done *** +
-*** Creating initramfs image file '/tmp/initramfs' done ***+
 </code> </code>
  
-Notez la présence de votre nouvelle image **/tmp/initrd/initramfs** :+Exécutez maintenant la commande suivante afin de générer le fichier **usbinitramfs** :
  
 <code> <code>
-[root@centos7 initrd]# ls -l /tmp/initrd/initramfs +root@debian11:/tmp/initrd# mkinitramfs -o usbinitramfs-`uname -r`.img
--rw-------. 1 root root 16373488 Jun 10 10:23 /tmp/initrd/initramfs+
 </code> </code>
  
-Déplacez votre fichier initramfs au répertoire /boot :+Notez la présence de votre nouvelle image **/tmp/initrd/usbinitramfs** :
  
 <code> <code>
-[root@centos7 initrd]mv initramfs /boot+root@debian11:/tmp/initrd# ls -l /tmp/initrd/usbinitramfs-5.10.0-13-amd64.img  
 +-rw-r--r-- 1 root root 47695493 Apr 30 11:12 /tmp/initrd/usbinitramfs-5.10.0-13-amd64.img
 </code> </code>
  
-Ouvrez votre fichier **/boot/grub2/grub.cfg** et cherchez la section **10_linux**. Copiez la première section **menuentry** :+Déplacez votre fichier usbinitramfs au répertoire /boot :
  
 <code> <code>
-... +root@debian11:/tmp/initrdmv usbinitramfs-5.10.0-13-amd64.img /boot
-### BEGIN /etc/grub.d/10_linux ### +
-menuentry 'CentOS Linux (3.10.0-229.4.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91'+
- load_video +
- set gfxpayload=keep +
- insmod gzio +
- insmod part_msdos +
- insmod xfs +
- set root='hd0,msdos1' +
- if [ x$feature_platform_search_hint = xy ]; then +
-   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309 +
- else +
-   search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309 +
- fi +
- linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.UTF-8 +
- initrd16 /initramfs-3.10.0-229.4.2.el7.x86_64.img +
-+
-...+
 </code> </code>
  
-Créez maintenant le fichier **/etc/grub.d/09_redhat**, collez la section précédemment copiée à la place indiquée entre les lignes **cat << EOF** et **EOF** puis modifiez la dernière ligne **initrd16** :+Créez maintenant le fichier **/etc/grub.d/09_usbdebian** :
  
-<file>+<code> 
 +root@debian11:/tmp/initrd# vi /etc/grub.d/09_usbdebian 
 +root@debian11:/tmp/initrd# cat /etc/grub.d/09_usbdebian
 #!/bin/sh -e #!/bin/sh -e
 cat << EOF cat << EOF
-menuentry 'CentOS Linux, with Linux 3.10.0-229.4.2.el7.x86_64 et initramfs' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.4.2.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' {+menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-9887a74f-a680-4bde-8f04-db5ae9ea186e' {
         load_video         load_video
-        set gfxpayload=keep 
         insmod gzio         insmod gzio
 +        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
         insmod part_msdos         insmod part_msdos
-        insmod xfs+        insmod ext2
         set root='hd0,msdos1'         set root='hd0,msdos1'
         if [ x$feature_platform_search_hint = xy ]; then         if [ x$feature_platform_search_hint = xy ]; then
-          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309+          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e
         else         else
-          search --no-floppy --fs-uuid --set=root e8d3bd48-1386-411c-9675-41c3f8f1a309+          search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e
         fi         fi
-        linux16 /vmlinuz-3.10.0-229.4.2.el7.x86_64 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rhgb quiet +        echo    'Loading Linux 5.10.0-13-amd64 ...
-        initrd16 /initramfs+        linux   /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro  quiet 
 +        echo    'Loading initial ramdisk ...' 
 +        initrd  /boot/usbinitramfs-5.10.0-13-amd64.img
 } }
 EOF EOF
-</file>+</code>
  
 Rendez ce fichier exécutable : Rendez ce fichier exécutable :
  
 <code> <code>
-[root@centos7 initrd]# chmod +x /etc/grub.d/09_redhat+root@debian11:/tmp/initrd# chmod +x /etc/grub.d/09_usbdebian
 </code> </code>
- 
-Avant de continuer, supprimer le fichier **/etc/grub.d/01_users** et éditez le contenu du fichier **/etc/grub.d/40_custom** ainsi : 
- 
-<file> 
-#!/bin/sh 
-exec tail -n +3 $0 
-# This file provides an easy way to add custom menu entries.  Simply type the 
-# menu entries you want to add after this comment.  Be careful not to change 
-# the 'exec tail' line above. 
-</file> 
  
 Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier : Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier :
  
 <code> <code>
-[root@centos7 initrd]grub2-mkconfig -o /boot/grub2/grub.cfg+root@debian11:/tmp/initrd# grub-mkconfig -o /boot/grub/grub.cfg
 Generating grub configuration file ... Generating grub configuration file ...
-Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 +Found background image: /usr/share/images/desktop-base/desktop-grub.png 
-Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img +Found linux image: /boot/vmlinuz-5.10.0-13-amd64 
-Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 +Found initrd image: /boot/initrd.img-5.10.0-13-amd64
-Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img +
-Found linux image: /boot/vmlinuz-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 +
-Found initrd image: /boot/initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img+
 done done
 </code> </code>
  
-Controlez le fichier /boot/grub2/grub.cfg :+Controlez le fichier /boot/grub/grub.cfg :
  
 <file> <file>
 ... ...
-### BEGIN /etc/grub.d/09_redhat ### +### END /etc/grub.d/05_debian_theme ### 
-menuentry 'CentOS Linux, with Linux 3.10.0-229.4.2.el7.x86_64 et initramfs' --class centos --class gnu-linux --class gnu --class os --unrestricted  'gnulinux-3.10.0-229.4.2.el7.x86_64-advanced-b35de665-5ec8-4226-a533-58a1b567ac91' {+ 
 +### BEGIN /etc/grub.d/09_usbdebian ### 
 +menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os  'gnulinux-simple-9887a74f-a680-4bde-8f04-db5ae9ea186e' {
         load_video         load_video
-        set gfxpayload=keep 
         insmod gzio         insmod gzio
 +        if [ x = xxen ]; then insmod xzio; insmod lzopio; fi
         insmod part_msdos         insmod part_msdos
-        insmod xfs+        insmod ext2
         set root='hd0,msdos1'         set root='hd0,msdos1'
         if [ x = xy ]; then         if [ x = xy ]; then
-          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  e8d3bd48-1386-411c-9675-41c3f8f1a309+          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  9887a74f-a680-4bde-8f04-db5ae9ea186e
         else         else
 +          search --no-floppy --fs-uuid --set=root 9887a74f-a680-4bde-8f04-db5ae9ea186e
 +        fi
 +        echo    'Loading Linux 5.10.0-13-amd64 ...'
 +        linux   /boot/vmlinuz-5.10.0-13-amd64 root=UUID=9887a74f-a680-4bde-8f04-db5ae9ea186e ro  quiet
 +        echo    'Loading initial ramdisk ...'
 +        initrd  /boot/usbinitramfs-5.10.0-13-amd64.img
 +}
 +### END /etc/grub.d/09_usbdebian ###
 +
 +### BEGIN /etc/grub.d/10_linux ###
 ... ...
 </file> </file>
  
-<WRAP center round todo> +=====Processus de Démarrage du Noyau Linux=====
-**A faire** : **Re-démarrez votre machine pour tester votre configuration.** +
-</WRAP> +
- +
-====Processus de Démarrage du Noyau Linux====+
  
 Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes : Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes :
Ligne 1568: Ligne 1348:
 La fonction **init_post()** essaie ensuite d'exécuter un des processus suivant dans l'ordre : La fonction **init_post()** essaie ensuite d'exécuter un des processus suivant dans l'ordre :
  
-  * /sbin/init+  * /sbin/init ==> /usr/sbin/init ==> /usr/lib/systemd/systemd
   * /etc/init   * /etc/init
   * /bin/init   * /bin/init
-  * /bin/sh +  * /bin/sh ==> /bin/bash ==> /usr/bin/bash
  
 Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché. Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché.
  
-====Processus Init====+=====Processus Init=====
  
 Le premier processus lancé par le noyau est **Init**. L'exécutable lancé est **/sbin/init**. Son rôle est de d'initialiser le système et de lancer certains autres services. Les tâches accomplies par init sont : Le premier processus lancé par le noyau est **Init**. L'exécutable lancé est **/sbin/init**. Son rôle est de d'initialiser le système et de lancer certains autres services. Les tâches accomplies par init sont :
Ligne 1806: Ligne 1586:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Notez que chaque répertoire correspondant à un niveau d'exécution contient des liens pointant vers un script dans le répertoire **/etc/init.d**. La lettre **S** indique au script **rc** que le script dans **/etc/rc.d/init.d** doit être exécutée avec l'option **start**. De cette façon les processus sont lancés dans le niveau d'exécution spécifié. Le numéro qui suit la lettre **S** indique l'ordre de lancement par le script **rc**. Si deux scripts dans un répertoire **/etc/rc.d/rcX.d** ont le même numéro, l'ordre alphabétique prime. Notez aussi la présence du lien **S99local** qui lance le script **rc.local** en dernier. Le script rc.local est lancé dans les niveaux d'exécution **2, 3, 4 et 5**. C'est dans ce script que **root** peut ajouter des commandes. **Important** : Notez que chaque répertoire correspondant à un niveau d'exécution contient des liens pointant vers un script dans le répertoire **/etc/init.d**. La lettre **S** indique au script **rc** que le script dans **/etc/rc.d/init.d** doit être exécutée avec l'option **start**. De cette façon les processus sont lancés dans le niveau d'exécution spécifié. Le numéro qui suit la lettre **S** indique l'ordre de lancement par le script **rc**. Si deux scripts dans un répertoire **/etc/rc.d/rcX.d** ont le même numéro, l'ordre alphabétique prime. Notez aussi la présence du lien **S99local** qui lance le script **rc.local** en dernier. Le script rc.local est lancé dans les niveaux d'exécution **2, 3, 4 et 5**. C'est dans ce script que **root** peut ajouter des commandes.
 </WRAP> </WRAP>
Ligne 1831: Ligne 1611:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Ici le principe est le même sauf que la lettre **K** indique au script **rc** que le script dans **/etc/rc.d/init.d** doit être lancé avec l'option **stop**. **Important** : Ici le principe est le même sauf que la lettre **K** indique au script **rc** que le script dans **/etc/rc.d/init.d** doit être lancé avec l'option **stop**.
 </WRAP> </WRAP>
Ligne 2288: Ligne 2068:
   # update-rc.d ssh start 20 2 3 4 5 . stop 20 0 1 6 . [Entrée]   # update-rc.d ssh start 20 2 3 4 5 . stop 20 0 1 6 . [Entrée]
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** :  **Important** : 
 Il existe aussi un mot clef : **default**. Ce mot clef indique à **update-rc.d** d'utiliser les valeurs spécifiées dans la command précédente. Il existe aussi un mot clef : **default**. Ce mot clef indique à **update-rc.d** d'utiliser les valeurs spécifiées dans la command précédente.
Ligne 2297: Ligne 2077:
   # update-rc.d -f ssh remove [Entrée]   # update-rc.d -f ssh remove [Entrée]
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** :  **Important** : 
 Cette commande laisse le script ssh dans le répertoire /etc/init.d. Cette commande laisse le script ssh dans le répertoire /etc/init.d.
Ligne 2541: Ligne 2321:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 **Important** : Notez qu'à part la deuxième ligne de la description, chaque ligne **doit** commencer par le caractère **#** suivi par un espace. **Important** : Notez qu'à part la deuxième ligne de la description, chaque ligne **doit** commencer par le caractère **#** suivi par un espace.
 </WRAP> </WRAP>
Ligne 2568: Ligne 2348:
 | $syslog | Syslog, Syslog-ng ou Rsyslog doit être démarré. | | $syslog | Syslog, Syslog-ng ou Rsyslog doit être démarré. |
 | $time | L'heure du système doit avoir été fixé soit par NTP, soit par rdate soit par l'horloge système. | | $time | L'heure du système doit avoir été fixé soit par NTP, soit par rdate soit par l'horloge système. |
- 
  
 =====Démarrer RHEL/CentOS 6 avec Upstart===== =====Démarrer RHEL/CentOS 6 avec Upstart=====
Ligne 3059: Ligne 2838:
 </code> </code>
  
-<WRAP center round important>+<WRAP center round important 60% >
 Il est aussi possible d'utiliser les commandes **initctl start**, **initctl stop** et **initctl restart** pour gérer les jobs. Il est aussi possible d'utiliser les commandes **initctl start**, **initctl stop** et **initctl restart** pour gérer les jobs.
 </WRAP> </WRAP>
  
-=====Démarrer RHEL/CentOS 7=====+=====Démarrer Debian 11 avec Systemd=====
  
-RHEL/CentOS 7, comme beaucoup d'autres distributions, ont abandonné **Upstart** pour **Systemd**. Ce dernier prend une approche différente au démarrage de Linux. En effet, **SysVinit** et **Upstart** sont des systèmes de démarrage **séquentiels**. **Systemd** essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d'architectures matérielles modernes sont multi-cœurs. Si un service dépend d'un autre qui n'est pas encore démarré ce premier est mis en attente dans une mémoire tampon. Qui plus est, les services qui ne sont pas nécessaires au démarrage de la machine, tel cups, ne sont démarrés ultérieurement que si nécessaire. Lors de démarrage, les partitions sont montées en parallèle. Dernièrement, **Systemd** remplace les scripts de démarrage traditionnels avec des binaires compilés, beaucoup plus rapides que leur prédécesseurs.+Les systèmes de démarrage antérieurs à Systemd, **SysVinit** et **Upstart**, étaient des systèmes de démarrage **séquentiels**. 
  
-Au lieu de parler de scripts de démarrage et de niveaux d'exécution, **Systemd** utilise la terminologie **Unités** (//Units//) et **Cibles** (//Targets//)Une Cible est en quelque sorte une **grande étape** dans le démarrage du système tandis qu'une Unité peut être :+**Systemd** essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d'architectures matérielles modernes sont multi-cœursSi un service dépend d'un autre qui n'est pas encore démarré ce premier est mis en attente dans une mémoire tampon. Qui plus est, les services qui ne sont pas nécessaires au démarrage de la machine, tel cups, ne sont démarrés ultérieurement que si nécessaire. Lors de démarrage, les partitions sont montées en parallèle. Dernièrement, **Systemd** remplace les scripts de démarrage traditionnels avec des binaires compilés, beaucoup plus rapides que leur prédécesseurs.
  
-  * un automount - (.automount), +Au lieu de parler de scripts de démarrage et de niveaux d'exécution, **Systemd** utilise la terminologie **Unités** (//Units//) et **Cibles** (//Targets//). Une Unité peut être :
-  * une périphérique - //Device// - (.device), +
-  * un montage d'un périphérique - //Mount// - (.mount), +
-  un chemin - //Path// - (.path) +
-  un socket - //Socket// - (.socket), +
-  * un service - //Service// - (.service)+
-  une instantanée - //Snapshot//(.snapshot), +
-  * une cible - //Target// - (.target).+
  
-<WRAP center round important> +  * **.automount** - active la fonctionalité d'automount. 
-**Important** : Dans le contexte d'une Unité, le type **cible** regroupe des Unités multiples afin qu'elles puissent être démarrées en même temps. Par exemple **network.target** regroupe toutes les Unités nécessaires pour démarrer toutes les interfaces réseaux en même temps. +  * **.device** - expose une périphérique dans systemd. 
-</WRAP>+  * **.mount** - contrôle quand et comment les systèmes de fichiers sont montés. 
 +  * **.path** - active un service quand il y a un accès à un fichier ou répertoire sous surveillance par le système. 
 +  * **.service** - démarre, arrête, redémarre ou recharge un service. 
 +  * **.scope** - gère des services. 
 +  * **.slice** - regroupe des Unités dans une arborescence afin de limiter des ressources en utilisant des CGroups. 
 +  * **.snapshot** - un état sauvegardé du gestionnaire Systemd. 
 +  * **.socket** - permet aux Unités d'utiliser des sockets pour la communication inter-processus. 
 +  * **.swap** - encapsule une périphérique ou un fichier swap. 
 +  * **.timer** - déclenche l'activation d'autres Unités en utilisant des minuteurs de Systemd. 
 +  * **.target** regroupe des Unités multiples afin qu'elles puissent être démarrées en même temps. Par exemple **network.target** regroupe toutes les Unités nécessaires pour démarrer toutes les interfaces réseaux en même temps. 
 + 
 +Une Cible est en quelque sorte une **grande étape** dans le démarrage du système : 
 + 
 +  * **halt.target** - arrête le système. 
 +  * **poweroff.target** - arrête le système et coupe le courant. 
 +  * **shutdown.target** - arrête le système. 
 +  * **rescue.target** - démarre le système en mode single-user (seul root peut s'y connecter). Tous les systèmes de fichiers sont montés mais le réseau n'est pas démarré. 
 +  * **emergency.target** - démarre le système en mode single-user (seul root peut s'y connecter). Uniquement le système de fichiers racine est monté en mode lecture seule. Le réseau n'est pas démarré. 
 +  * **multi-user.target** - démarre le système en mode multi-utilisateur avec tous les systèmes de fichiers montés et le service network démarré. 
 +  * **graphical.target** - démarre le système en multi-user.target puis démarre l'interface graphique. 
 +  * **hibernate.target** - sauvegarde l'état courant sur disque et arrête le système. Quand le système est démarré, l'état est restauré. 
 +  * **reboot.target** - redémarre le système. 
 + 
 +**Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d'exécution. Pour rendre la transition plus facile, il existe des **Cibles** qui "simulent" les niveaux d'exécution de **SysVinit** : 
 + 
 +<code> 
 +root@debian11:/tmp/initrd# ls -l /usr/lib/systemd/system/runlevel* 
 +lrwxrwxrwx 1 root root   15 Mar 20 20:55 /usr/lib/systemd/system/runlevel0.target -> poweroff.target 
 +lrwxrwxrwx 1 root root   13 Mar 20 20:55 /usr/lib/systemd/system/runlevel1.target -> rescue.target 
 +lrwxrwxrwx 1 root root   17 Mar 20 20:55 /usr/lib/systemd/system/runlevel2.target -> multi-user.target 
 +lrwxrwxrwx 1 root root   17 Mar 20 20:55 /usr/lib/systemd/system/runlevel3.target -> multi-user.target 
 +lrwxrwxrwx 1 root root   17 Mar 20 20:55 /usr/lib/systemd/system/runlevel4.target -> multi-user.target 
 +lrwxrwxrwx 1 root root   16 Mar 20 20:55 /usr/lib/systemd/system/runlevel5.target -> graphical.target 
 +lrwxrwxrwx 1 root root   13 Mar 20 20:55 /usr/lib/systemd/system/runlevel6.target -> reboot.target 
 + 
 +/usr/lib/systemd/system/runlevel1.target.wants: 
 +total 0 
 + 
 +/usr/lib/systemd/system/runlevel2.target.wants: 
 +total 0 
 + 
 +/usr/lib/systemd/system/runlevel3.target.wants: 
 +total 0 
 + 
 +/usr/lib/systemd/system/runlevel4.target.wants: 
 +total 0 
 + 
 +/usr/lib/systemd/system/runlevel5.target.wants: 
 +total 0 
 +</code>
  
-====La Commande systemctl====+====LAB #2 - La Commande systemctl====
  
 Pour visualiser la liste des Unités, il convient d'utiliser la commande **systemctl** avec l'option **list-units** : Pour visualiser la liste des Unités, il convient d'utiliser la commande **systemctl** avec l'option **list-units** :
  
 <code> <code>
-[root@centos7 ~]# systemctl list-units +root@debian11:/tmp/initrd# cd ~ 
-UNIT                                                           LOAD   ACTIVE SUB       DESCRIPTION +root@debian11:~# systemctl list-units 
-proc-sys-fs-binfmt_misc.automount                              loaded active waiting   Arbitrary Executable File Formats File System Automount Point +  UNIT                                                                                         LOAD   ACTIVE SUB       DESCRIPTION 
-sys-devices-pci0000:...t1-target1:0:0-1:0:0:0-block-sr0.device loaded active plugged   VBOX_CD-ROM +  proc-sys-fs-binfmt_misc.automount                                                            loaded active waiting   Arbitrary Executable File Formats File System Automount Point                 
-sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device          loaded active plugged   PRO/1000 MT Desktop Adapter +  sys-devices-pci0000:00-0000:00:01.1-ata2-host1-target1:0:0-1:0:0:0-block-sr0.device          loaded active plugged   QEMU_DVD-ROM Debian_11.3.0_amd64_n 
-sys-devices-pci0000:00-0000:00:05.0-sound-card0.device         loaded active plugged   82801AA AC'97 Audio Controller +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:0-block-sdb-sdb1.device  loaded active plugged   QEMU_HARDDISK 1 
-sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda1.device loaded active plugged   VBOX_HARDDISK +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:0-block-sdb-sdb2.device  loaded active plugged   QEMU_HARDDISK 2 
-sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda2.device loaded active plugged   VBOX_HARDDISK +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:0-block-sdb-sdb5.device  loaded active plugged   QEMU_HARDDISK 5 
-sys-devices-pci0000:...rget2:0:0-2:0:0:0-block-sda-sda3.device loaded active plugged   VBOX_HARDDISK +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:0-block-sdb.device       loaded active plugged   QEMU_HARDDISK 
-sys-devices-pci0000:...t2-target2:0:0-2:0:0:0-block-sda.device loaded active plugged   VBOX_HARDDISK +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc1.device  loaded active plugged   QEMU_HARDDISK 1 
-sys-devices-platform-serial8250-tty-ttyS0.device               loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS0 +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc10.device loaded active plugged   QEMU_HARDDISK 10 
-sys-devices-platform-serial8250-tty-ttyS1.device               loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS1 +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc11.device loaded active plugged   QEMU_HARDDISK 11 
-sys-devices-platform-serial8250-tty-ttyS2.device               loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS2 +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc12.device loaded active plugged   QEMU_HARDDISK 12 
-sys-devices-platform-serial8250-tty-ttyS3.device               loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS3 +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc2.device  loaded active plugged   QEMU_HARDDISK 2 
-sys-module-configfs.device                                     loaded active plugged   /sys/module/configfs +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc3.device  loaded active plugged   QEMU_HARDDISK 3 
-sys-module-fuse.device                                         loaded active plugged   /sys/module/fuse +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc4.device  loaded active plugged   QEMU_HARDDISK 4 
-sys-subsystem-net-devices-enp0s3.device                        loaded active plugged   PRO/1000 MT Desktop Adapter +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc5.device  loaded active plugged   QEMU_HARDDISK 5 
--.mount                                                        loaded active mounted   +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc6.device  loaded active plugged   QEMU_HARDDISK 6 
-boot.mount                                                     loaded active mounted   /boot +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc7.device  loaded active plugged   QEMU_HARDDISK 7 
-dev-hugepages.mount                                            loaded active mounted   Huge Pages File System +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc8.device  loaded active plugged   QEMU_HARDDISK my_reiserfs 
-dev-mqueue.mount                                               loaded active mounted   POSIX Message Queue File System +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc-sdc9.device  loaded active plugged   QEMU_HARDDISK 9 
-proc-fs-nfsd.mount                                             loaded active mounted   NFSD configuration filesystem +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:1-block-sdc.device       loaded active plugged   QEMU_HARDDISK 
-run-media-trainee-VBOXADDITIONS_4.3.28_100309.mount            loaded active mounted   /run/media/trainee/VBOXADDITIONS_4.3.28_100309 +  sys-devices-pci0000:00-0000:00:05.0-virtio1-host2-target2:0:0-2:0:0:2-block-sda.device       loaded active plugged   QEMU_HARDDISK 
-run-user-1000-gvfs.mount                                       loaded active mounted   /run/user/1000/gvfs +  sys-devices-pci0000:00-0000:00:12.0-virtio2-net-ens18.device                                 loaded active plugged   Virtio network device 
-sys-fs-fuse-connections.mount                                  loaded active mounted   FUSE Control File System +  sys-devices-platform-serial8250-tty-ttyS0.device                                             loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS0 
-sys-kernel-config.mount                                        loaded active mounted   Configuration File System +  sys-devices-platform-serial8250-tty-ttyS1.device                                             loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS1 
-sys-kernel-debug.mount                                         loaded active mounted   Debug File System +  sys-devices-platform-serial8250-tty-ttyS2.device                                             loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS2 
-var-lib-nfs-rpc_pipefs.mount                                   loaded active mounted   RPC Pipe File System +  sys-devices-platform-serial8250-tty-ttyS3.device                                             loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS3 
-brandbot.path                                                  loaded active waiting   Flexible branding +  sys-devices-virtual-block-dm\x2d0.device                                                     loaded active plugged   /sys/devices/virtual/block/dm-0 
-cups.path                                                      loaded active waiting   CUPS Printer Service Spool +  sys-devices-virtual-block-dm\x2d1.device                                                     loaded active plugged   /sys/devices/virtual/block/dm-1 
-systemd-ask-password-plymouth.path                             loaded active waiting   Forward Password Requests to Plymouth Directory Watch +  sys-devices-virtual-block-dm\x2d2.device                                                     loaded active plugged   /sys/devices/virtual/block/dm-2 
-systemd-ask-password-wall.path                                 loaded active waiting   Forward Password Requests to Wall Directory Watch +  sys-devices-virtual-misc-rfkill.device                                                       loaded active plugged   /sys/devices/virtual/misc/rfkill 
-session-1.scope                                                loaded active running   Session 1 of user trainee +  sys-module-configfs.device                                                                   loaded active plugged   /sys/module/configfs 
-abrt-ccpp.service                                              loaded active exited    Install ABRT coredump hook +  sys-module-fuse.device                                                                       loaded active plugged   /sys/module/fuse 
-abrt-oops.service                                              loaded active running   ABRT kernel log watcher +  sys-subsystem-net-devices-ens18.device                                                       loaded active plugged   Virtio network device                                                         
-abrt-xorg.service                                              loaded active running   ABRT Xorg log watcher +  -.mount                                                                                      loaded active mounted   Root Mount 
-abrtd.service                                                  loaded active running   ABRT Automated Bug Reporting Tool +  dev-hugepages.mount                                                                          loaded active mounted   Huge Pages File System 
-accounts-daemon.service                                        loaded active running   Accounts Service +  dev-mqueue.mount                                                                             loaded active mounted   POSIX Message Queue File System 
-alsa-state.service                                             loaded active running   Manage Sound Card State (restore and store) +  mnt-sdc11.mount                                                                              loaded active mounted   /mnt/sdc11 
-atd.service                                                    loaded active running   Job spooling tools +  mnt-sdc12.mount                                                                              loaded active mounted   /mnt/sdc12 
-auditd.service                                                 loaded active running   Security Auditing Service +  run-user-1000.mount                                                                          loaded active mounted   /run/user/1000 
-avahi-daemon.service                                           loaded active running   Avahi mDNS/DNS-SD Stack +  run-user-113.mount                                                                           loaded active mounted   /run/user/113 
-bluetooth.service                                              loaded active running   Bluetooth service +  sys-fs-fuse-connections.mount                                                                loaded active mounted   FUSE Control File System 
-chronyd.service                                                loaded active running   NTP client/server +  sys-kernel-config.mount                                                                      loaded active mounted   Kernel Configuration File System 
-colord.service                                                 loaded active running   Manage, Install and Generate Color Profiles +  sys-kernel-debug.mount                                                                       loaded active mounted   Kernel Debug File System 
-crond.service                                                  loaded active running   Command Scheduler +  sys-kernel-tracing.mount                                                                     loaded active mounted   Kernel Trace File System                                                      
-cups.service                                                   loaded active running   CUPS Printing Service +  cups.path                                                                                    loaded active running   CUPS Scheduler 
-dbus.service                                                   loaded active running   D-Bus System Message Bus +  systemd-ask-password-plymouth.path                                                           loaded active waiting   Forward Password Requests to Plymouth Directory Watch 
-firewalld.service                                              loaded active running   firewalld - dynamic firewall daemon +  systemd-ask-password-wall.path                                                               loaded active waiting   Forward Password Requests to Wall Directory Watch                             
-gdm.service                                                    loaded active running   GNOME Display Manager +  init.scope                                                                                   loaded active running   System and Service Manager 
-gssproxy.service                                               loaded active running   GSSAPI Proxy Daemon +  session-180.scope                                                                            loaded active running   Session 180 of user trainee 
-iscsi-shutdown.service                                         loaded active exited    Logout off all iSCSI sessions on shutdown +  session-c1.scope                                                                             loaded active running   Session c1 of user lightdm                                                    
-kdump.service                                                  loaded failed failed    Crash recovery kernel arming +  apparmor.service                                                                             loaded active exited    Load AppArmor profiles 
-kmod-static-nodes.service                                      loaded active exited    Create list of required static device nodes for the current ker +  auditd.service                                                                               loaded active running   Security Auditing Service 
-ksm.service                                                    loaded active exited    Kernel Samepage Merging +  avahi-daemon.service                                                                         loaded active running   Avahi mDNS/DNS-SD Stack 
-ksmtuned.service                                               loaded active running   Kernel Samepage Merging (KSM) Tuning Daemon +  blk-availability.service                                                                     loaded active exited    Availability of block devices 
-libstoragemgmt.service                                         loaded active running   libstoragemgmt plug-in server daemon +  console-setup.service                                                                        loaded active exited    Set console font and keymap 
-libvirtd.service                                               loaded active running   Virtualization daemon +  cron.service                                                                                 loaded active running   Regular background program processing daemon 
-lvm2-lvmetad.service                                           loaded active running   LVM2 metadata daemon+  cups-browsed.service                                                                         loaded active running   Make remote CUPS printers available locally 
 +  cups.service                                                                                 loaded active running   CUPS Scheduler 
 +lines 1-58 
 +[q]
 </code> </code>
  
Ligne 3151: Ligne 2975:
  
 <code> <code>
-[root@centos7 ~]# systemctl list-units --all | grep inactive | more +root@debian11:~# systemctl list-units --all | grep inactive | more 
-proc-sys-fs-binfmt_misc.mount                                                             loaded inactive dead      Arbitrary Executable File Formats  +● home.mount                                                                                                     not-found inactive dead      home.mount 
-File System +  proc-sys-fs-binfmt_misc.mount                                                                                  loaded    inactive dead      Arbitrary Executable File Formats File System 
-systemd-ask-password-console.path                                                         loaded inactive dead      Dispatch Password Requests to Cons +● tmp.mount                                                                                                      not-found inactive dead      tmp.mount 
-ole Directory Watch +  systemd-ask-password-console.path                                                                              loaded    inactive dead      Dispatch Password Requests to Console Directory Watch 
-abrt-vmcore.service                                                                       loaded inactive dead      Harvest vmcores for ABRT +  anacron.service                                                                                                loaded    inactive dead      Run anacron jobs 
-alsa-restore.service                                                                      loaded inactive dead      Restore Sound Card State +  apt-daily-upgrade.service                                                                                      loaded    inactive dead      Daily apt upgrade and clean activities 
-alsa-store.service                                                                        loaded inactive dead      Store Sound Card State +  apt-daily.service                                                                                              loaded    inactive dead      Daily apt download activities 
-apparmor.service                                                                          not-found inactive dead      apparmor.service +● connman.service                                                                                                not-found inactive dead      connman.service 
-auth-rpcgss-module.service                                                                loaded inactive dead      Kernel Module supporting RPCSEC_GS +● console-screen.service                                                                                         not-found inactive dead      console-screen.service 
-S +  dm-event.service                                                                                               loaded    inactive dead      Device-mapper event daemon 
-brandbot.service                                                                          loaded inactive dead      Flexible Branding Service +  e2scrub_all.service                                                                                            loaded    inactive dead      Online ext4 Metadata Check for All Filesystems 
-cpupower.service                                                                          loaded inactive dead      Configure CPU power related settin +  e2scrub_reap.service                                                                                           loaded    inactive dead      Remove Stale Online ext4 Metadata Check Snapshots 
-gs +  emergency.service                                                                                              loaded    inactive dead      Emergency Shell 
-dm-event.service                                                                          loaded inactive dead      Device-mapper event daemon +● fcoe.service                                                                                                   not-found inactive dead      fcoe.service 
-dmraid-activation.service                                                                 loaded inactive dead      Activation of DM RAID sets +  fstrim.service                                                                                                 loaded    inactive dead      Discard unused blocks on filesystems from /etc/fstab 
-dracut-shutdown.service                                                                   loaded inactive dead      Restore /run/initramfs +  getty-static.service                                                                                           loaded    inactive dead      getty on tty2-tty6 if dbus and logind are not available 
-ebtables.service                                                                          loaded inactive dead      Ethernet Bridge Filtering tables +● iscsi-shutdown.service                                                                                         not-found inactive dead      iscsi-shutdown.service 
-emergency.service                                                                         loaded inactive dead      Emergency Shell +● iscsi.service                                                                                                  not-found inactive dead      iscsi.service 
-exim.service                                                                              not-found inactive dead      exim.service +● iscsid.service                                                                                                 not-found inactive dead      iscsid.service 
-getty@tty1.service                                                                        loaded inactive dead      Getty on tty1 +● kbd.service                                                                                                    not-found inactive dead      kbd.service 
-hypervkvpd.service                                                                        loaded inactive dead      Hyper-V KVP daemon +  logrotate.service                                                                                              loaded    inactive dead      Rotate log files 
-hypervvssd.service                                                                        loaded inactive dead      Hyper-V VSS daemon +● lvm2-activation.service                                                                                        not-found inactive dead      lvm2-activation.service 
-ip6tables.service                                                                         loaded inactive dead      IPv6 firewall with ip6tables +  lvm2-lvmpolld.service                                                                                          loaded    inactive dead      LVM2 poll daemon 
-iptables.service                                                                          loaded inactive dead      IPv4 firewall with iptables +  man-db.service                                                                                                 loaded    inactive dead      Daily man-db regeneration 
-irqbalance.service                                                                        loaded inactive dead      irqbalance daemon +  mlocate.service                                                                                                loaded    inactive dead      Update a database for mlocate 
-iscsi.service                                                                             loaded inactive dead      Login and scanning of iSCSI device +  modprobe@configfs.service                                                                                      loaded    inactive dead      Load Kernel Module configfs 
-s +  modprobe@drm.service                                                                                           loaded    inactive dead      Load Kernel Module drm 
-iscsid.service                                                                            loaded inactive dead      Open-iSCSI +  modprobe@fuse.service                                                                                          loaded    inactive dead      Load Kernel Module fuse 
-iscsiuio.service                                                                          loaded inactive dead      iSCSI UserSpace I/O driver+● nslcd.service                                                                                                  not-found inactive dead      nslcd.service 
 +  plymouth-quit.service                                                                                          loaded    inactive dead      Terminate Plymouth Boot Screen 
 +● rbdmap.service                                                                                                 not-found inactive dead      rbdmap.service 
 +  rc-local.service                                                                                               loaded    inactive dead      /etc/rc.local Compatibility 
 +  rescue.service                                                                                                 loaded    inactive dead      Rescue Shell 
 +  rsync.service                                                                                                  loaded    inactive dead      fast remote file copy program daemon 
 +● sssd.service                                                                                                   not-found inactive dead      sssd.service 
 +  systemd-ask-password-console.service                                                                           loaded    inactive dead      Dispatch Password Requests to Console 
 +  systemd-ask-password-plymouth.service                                                                          loaded    inactive dead      Forward Password Requests to Plymouth 
 +  systemd-ask-password-wall.service                                                                              loaded    inactive dead      Forward Password Requests to Wall 
 +  systemd-binfmt.service                                                                                         loaded    inactive dead      Set Up Additional Binary Formats 
 +  systemd-boot-system-token.service                                                                              loaded    inactive dead      Store a System Token in an EFI Variable 
 +  systemd-cryptsetup@sdc11.service                                                                               loaded    inactive dead      Cryptography Setup for sdc11 
 +  systemd-fsck-root.service                                                                                      loaded    inactive dead      File System Check on Root Device 
 +  systemd-fsck@dev-mapper-sdc11.service                                                                          loaded    inactive dead      File System Check on /dev/mapper/sdc11 
 +  systemd-fsckd.service                                                                                          loaded    inactive dead      File System Check Daemon to report status 
 +  systemd-hwdb-update.service                                                                                    loaded    inactive dead      Rebuild Hardware Database 
 +  systemd-initctl.service                                                                                        loaded    inactive dead      initctl Compatibility Daemon 
 +  systemd-machine-id-commit.service                                                                              loaded    inactive dead      Commit a transient machine-id on disk 
 +  systemd-networkd.service                                                                                       loaded    inactive dead      Network Service 
 +  systemd-pstore.service                                                                                         loaded    inactive dead      Platform Persistent Storage Archival 
 +  systemd-quotacheck.service                                                                                     loaded    inactive dead      File System Quota Check 
 +  systemd-rfkill.service                                                                                         loaded    inactive dead      Load/Save RF Kill Switch Status 
 +  systemd-tmpfiles-clean.service                                                                                 loaded    inactive dead      Cleanup of Temporary Directories 
 +● systemd-update-done.service                                                                                    not-found inactive dead      systemd-update-done.service 
 +  systemd-update-utmp-runlevel.service                                                                           loaded    inactive dead      Update UTMP about System Runlevel Changes 
 +● systemd-vconsole-setup.service                                                                                 not-found inactive dead      systemd-vconsole-setup.service 
 +● ypbind.service                                                                                                 not-found inactive dead      ypbind.service 
 +  system-systemd\x2dcryptsetup.slice                                                                             loaded    inactive dead      Cryptsetup Units Slice 
 +  system-systemd\x2dfsck.slice                                                                                   loaded    inactive dead      system-systemd\x2dfsck.slice
 --More-- --More--
 +[q]
 </code> </code>
  
-Pour consulter la liste des fichiers Unitésutilisez la commande suivante :+Les points noirs au début de certaines lignes dans la sortie ci-dessus sont en réalité des points blancs à l'écran. Ces points impliquent que le service, la cible ou l'unité spécifié n'a pas été trouvé sur le système. Par exemple :
  
 <code> <code>
-[root@centos7 ~]# systemctl list-unit-files | more +root@debian11:~# systemctl status connman 
-UNIT FILE                                   STATE    +Unit connman.service could not be found. 
-proc-sys-fs-binfmt_misc.automount           static   +</code> 
-dev-hugepages.mount                         static   + 
-dev-mqueue.mount                            static   +Pour consulter la liste des Unités ainsi que leurs statuts, utilisez la commande suivante : 
-proc-fs-nfsd.mount                          static   + 
-proc-sys-fs-binfmt_misc.mount               static   +<code> 
-sys-fs-fuse-connections.mount               static   +root@debian11:~# systemctl list-unit-files | more 
-sys-kernel-config.mount                     static   +UNIT FILE                                                                 STATE           VENDOR PRESET 
-sys-kernel-debug.mount                      static   +proc-sys-fs-binfmt_misc.automount                                         static          - 
-tmp.mount                                   disabled +-.mount                                                                   generated       - 
-var-lib-nfs-rpc_pipefs.mount                static   +dev-hugepages.mount                                                       static          - 
-brandbot.path                               disabled +dev-mqueue.mount                                                          static          - 
-cups.path                                   enabled  +media-cdrom0.mount                                                        generated       - 
-systemd-ask-password-console.path           static   +mnt-sdc11.mount                                                           generated       - 
-systemd-ask-password-plymouth.path          static   +proc-sys-fs-binfmt_misc.mount                                             disabled        disabled 
-systemd-ask-password-wall.path              static   +sys-fs-fuse-connections.mount                                             static          - 
-session-1.scope                             static   +sys-kernel-config.mount                                                   static          - 
-session-8.scope                             static   +sys-kernel-debug.mount                                                    static          - 
-abrt-ccpp.service                           enabled  +sys-kernel-tracing.mount                                                  static          - 
-abrt-oops.service                           enabled  +cups.path                                                                 enabled         enabled 
-abrt-pstoreoops.service                     disabled +systemd-ask-password-console.path                                         static          - 
-abrt-vmcore.service                         enabled  +systemd-ask-password-plymouth.path                                        static          - 
-abrt-xorg.service                           enabled  +systemd-ask-password-wall.path                                            static          - 
-abrtd.service                               enabled  +session-180.scope                                                         transient       - 
-accounts-daemon.service                     enabled  +session-c1.scope                                                          transient       - 
-alsa-restore.service                        static   +alsa-restore.service                                                      static          - 
-alsa-state.service                          static   +alsa-state.service                                                        static          - 
-alsa-store.service                          static   +alsa-utils.service                                                        masked          enabled 
-anaconda-direct.service                     static  +anacron.service                                                           enabled         enabled 
 +apparmor.service                                                          enabled         enabled 
 +apt-daily-upgrade.service                                                 static          - 
 +apt-daily.service                                                         static          - 
 +auditd.service                                                            enabled         enabled 
 +autovt@.service                                                           alias           - 
 +avahi-daemon.service                                                      enabled         enabled 
 +blk-availability.service                                                  enabled         enabled 
 +colord.service                                                            static          - 
 +configure-printer@.service                                                static          - 
 +console-getty.service                                                     disabled        disabled 
 +console-setup.service                                                     enabled         enabled 
 +container-getty@.service                                                  static          - 
 +cron.service                                                              enabled         enabled 
 +cryptdisks-early.service                                                  masked          enabled 
 +cryptdisks.service                                                        masked          enabled 
 +cups-browsed.service                                                      enabled         enabled 
 +cups.service                                                              enabled         enabled 
 +dbus-fi.w1.wpa_supplicant1.service                                        alias           - 
 +dbus-org.freedesktop.Avahi.service                                        alias           - 
 +dbus-org.freedesktop.hostname1.service                                    alias           - 
 +dbus-org.freedesktop.locale1.service                                      alias           - 
 +dbus-org.freedesktop.login1.service                                       alias           - 
 +dbus-org.freedesktop.ModemManager1.service                                alias           - 
 +dbus-org.freedesktop.nm-dispatcher.service                                alias           - 
 +dbus-org.freedesktop.timedate1.service                                    alias           - 
 +dbus-org.freedesktop.timesync1.service                                    alias           - 
 +dbus.service                                                              static          - 
 +debug-shell.service                                                       disabled        disabled 
 +display-manager.service                                                   alias           - 
 +dm-event.service                                                          static          - 
 +e2scrub@.service                                                          static          - 
 +e2scrub_all.service                                                       static          - 
 +e2scrub_fail@.service                                                     static          - 
 +e2scrub_reap.service                                                      enabled         enabled 
 +emergency.service                                                         static          - 
 +fstrim.service                                                            static          -
 --More-- --More--
 +[q]
 </code> </code>
  
-===Options de la Commande systemctl===+Pour visualiser les Unités d'un type spécifique, il convient d'utiliser l'option **-t** :
  
-Les options de la commande **systemctl** sont :+<code> 
 +root@debian11:~# systemctl list-unit-files -t mount 
 +UNIT FILE                     STATE     VENDOR PRESET 
 +-.mount                       generated -             
 +dev-hugepages.mount           static    -             
 +dev-mqueue.mount              static    -             
 +media-cdrom0.mount            generated -             
 +mnt-sdc11.mount               generated -             
 +proc-sys-fs-binfmt_misc.mount disabled  disabled      
 +sys-fs-fuse-connections.mount static    -             
 +sys-kernel-config.mount       static    -             
 +sys-kernel-debug.mount        static    -             
 +sys-kernel-tracing.mount      static    -             
 + 
 +10 unit files listed. 
 +</code> 
 + 
 +Dans la colonne STATE on voit les mots **static** et **generated**.  
 + 
 +  * STATE = static 
 +    * Ceci implique que l'Unité ne peut ni être démarrée, ni être arrêtée par l'administrateur. Le démarrage et l'arrêt d'une telle Unité est effectué par le système. En règle générale, les Unités dont le STATE est static sont des dépendances d'autres Unité 
 + 
 +  * STATE = generated 
 +    * Ceci implique que le fichier a été généré automatiquement en utilisant les informations dans le fichier **/etc/fstab** lors du démarrage du système. Dans le cas d'un point de montage, l'exécutable respopnsable de la génération du fichier est **/lib/systemd/system-generators/systemd-fstab-generator** :
  
 <code> <code>
-[root@centos7 ~]systemctl --help +root@debian11:~# ls -l /lib/systemd/system-generators/systemd-fstab-generator 
-systemctl [OPTIONS...] {COMMAND} ...+-rwxr-xr-x 1 root root 43440 Mar 20 20:55 /lib/systemd/system-generators/systemd-fstab-generator 
 +</code>
  
-Query or send control commands to the systemd manager.+Il existe aussi d'autres exécutables responsables de la génération d'autres fichiers :
  
-  -h --help           Show this help +<code> 
-     --version        Show package version +root@debian11:~# ls -l /lib/systemd/system-generators 
-  ---type=TYPE      List only units of a particular type +total 420 
-     --state=STATE    List only units with particular LOAD or SUB or ACTIVE state +-rwxr-xr-x 1 root root 146872 Feb 22  2021 lvm2-activation-generator 
-  ---property=NAME  Show only properties by this name +-rwxr-xr-x 1 root root  14488 Mar 20 20:55 systemd-bless-boot-generator 
-  ---all            Show all loaded units/properties, including dead/empty +-rwxr-xr-x 1 root root  35176 Mar 20 20:55 systemd-cryptsetup-generator 
-                      ones. To list all units installed on the system, use +-rwxr-xr-x 1 root root  14632 Mar 20 20:55 systemd-debug-generator 
-                      the 'list-unit-files' command instead. +-rwxr-xr-x 1 root root  43440 Mar 20 20:55 systemd-fstab-generator 
-     --reverse        Show reverse dependencies with 'list-dependencies' +-rwxr-xr-x 1 root root  14480 Mar 20 20:55 systemd-getty-generator 
-  -l --full           Don't ellipsize unit names on output +-rwxr-xr-x 1 root root  34968 Mar 20 20:55 systemd-gpt-auto-generator 
-     --fail           When queueing a new job, fail if conflicting jobs are +-rwxr-xr-x 1 root root  14624 Mar 20 20:55 systemd-hibernate-resume-generator 
-                      pending +-rwxr-xr-x 1 root root  14480 Mar 20 20:55 systemd-rc-local-generator 
-     --irreversible   When queueing a new job, make sure it cannot be implicitly +-rwxr-xr-x 1 root root  14616 Mar 20 20:55 systemd-run-generator 
-                      cancelled +-rwxr-xr-x 1 root root  14480 Mar 20 20:55 systemd-system-update-generator 
-     --ignore-dependencies +-rwxr-xr-x 1 root root  30936 Mar 20 20:55 systemd-sysv-generator 
-                      When queueing a new job, ignore all its dependencies +-rwxr-xr-x 1 root root  14624 Mar 20 20:55 systemd-veritysetup-generator 
-     --show-types     When showing sockets, explicitly show their type +</code>
-  ---ignore-inhibitors +
-                      When shutting down or sleeping, ignore inhibitors +
-     --kill-who=WHO   Who to send signal to +
-  ---signal=SIGNAL  Which signal to send +
-  ---host=[USER@]HOST +
-                      Show information for remote host +
-  ---privileged     Acquire privileges before execution +
-  ---quiet          Suppress output +
-     --no-block       Do not wait until operation finished +
-     --no-wall        Don't send wall message before halt/power-off/reboot +
-     --no-reload      When enabling/disabling unit files, don't reload daemon +
-                      configuration +
-     --no-legend      Do not print a legend (column headers and hints) +
-     --no-pager       Do not pipe output into a pager +
-     --no-ask-password +
-                      Do not ask for system passwords +
-     --system         Connect to system manager +
-     --user           Connect to user service manager +
-     --global         Enable/disable unit files globally +
-     --runtime        Enable unit files only temporarily until next reboot +
-  -f --force          When enabling unit files, override existing symlinks +
-                      When shutting down, execute action immediately +
-     --root=PATH      Enable unit files in the specified root directory +
-  ---lines=INTEGER  Number of journal entries to show +
-  ---output=STRING  Change journal output mode (short, short-monotonic, +
-                      verbose, export, json, json-pretty, json-sse, cat) +
-     --plain          Print unit dependencies as a list instead of a tree+
  
-Unit Commands: +Les options de la commande **systemctl** sont :
-  list-units                      List loaded units +
-  list-sockets                    List loaded sockets ordered by address +
-  start [NAME...]                 Start (activate) one or more units +
-  stop [NAME...]                  Stop (deactivate) one or more units +
-  reload [NAME...]                Reload one or more units +
-  restart [NAME...]               Start or restart one or more units +
-  try-restart [NAME...]           Restart one or more units if active +
-  reload-or-restart [NAME...]     Reload one or more units if possible, +
-                                  otherwise start or restart +
-  reload-or-try-restart [NAME...] Reload one or more units if possible, +
-                                  otherwise restart if active +
-  isolate [NAME]                  Start one unit and stop all others +
-  kill [NAME...]                  Send signal to processes of a unit +
-  is-active [NAME...]             Check whether units are active +
-  is-failed [NAME...]             Check whether units are failed +
-  status [NAME...|PID...]         Show runtime status of one or more units +
-  show [NAME...|JOB...]           Show properties of one or more +
-                                  units/jobs or the manager +
-  set-property [NAME] [ASSIGNMENT...] +
-                                  Sets one or more properties of a unit +
-  help [NAME...|PID...]           Show manual for one or more units +
-  reset-failed [NAME...]          Reset failed state for all, one, or more +
-                                  units +
-  list-dependencies [NAME]        Recursively show units which are required +
-                                  or wanted by this unit or by which this +
-                                  unit is required or wanted+
  
-Unit File Commands: +<code> 
-  list-unit-files                 List installed unit files +root@debian11:~# systemctl --help 
-  enable [NAME...]                Enable one or more unit files +systemctl [OPTIONS...] COMMAND ...
-  disable [NAME...]               Disable one or more unit files +
-  reenable [NAME...]              Reenable one or more unit files +
-  preset [NAME...]                Enable/disable one or more unit files +
-                                  based on preset configuration +
-  is-enabled [NAME...]            Check whether unit files are enabled+
  
-  mask [NAME...]                  Mask one or more units +Query or send control commands to the system manager.
-  unmask [NAME...]                Unmask one or more units +
-  link [PATH...]                  Link one or more units files into +
-                                  the search path +
-  get-default                     Get the name of the default target +
-  set-default NAME                Set the default target+
  
-Job Commands: +Unit Commands: 
-  list-jobs                       List jobs +  list-units [PATTERN...]             List units currently in memory 
-  cancel [JOB...]                 Cancel all, one, or more jobs+  list-sockets [PATTERN...]           List socket units currently in memory, 
 +                                      ordered by address 
 +  list-timers [PATTERN...]            List timer units currently in memory, 
 +                                      ordered by next elapse 
 +  is-active PATTERN...                Check whether units are active 
 +  is-failed PATTERN...                Check whether units are failed 
 +  status [PATTERN...|PID...]          Show runtime status of one or more units 
 +  show [PATTERN...|JOB...]            Show properties of one or more 
 +                                      units/jobs or the manager 
 +  cat PATTERN...                      Show files and drop-ins of specified units 
 +  help PATTERN...|PID...              Show manual for one or more units 
 +  list-dependencies [UNIT...]         Recursively show units which are required 
 +                                      or wanted by the units or by which those 
 +                                      units are required or wanted 
 +  start UNIT...                       Start (activate) one or more units 
 +  stop UNIT...                        Stop (deactivate) one or more units 
 +  reload UNIT...                      Reload one or more units 
 +  restart UNIT...                     Start or restart one or more units 
 +  try-restart UNIT...                 Restart one or more units if active 
 +  reload-or-restart UNIT...           Reload one or more units if possible, 
 +                                      otherwise start or restart 
 +  try-reload-or-restart UNIT...       If active, reload one or more units, 
 +                                      if supported, otherwise restart 
 +  isolate UNIT                        Start one unit and stop all others 
 +  kill UNIT...                        Send signal to processes of a unit 
 +  clean UNIT...                       Clean runtime, cache, state, logs or 
 +                                      configuration of unit 
 +  freeze PATTERN...                   Freeze execution of unit processes 
 +  thaw PATTERN...                     Resume execution of a frozen unit 
 +  set-property UNIT PROPERTY=VALUE... Sets one or more properties of a unit 
 +  service-log-level SERVICE [LEVEL]   Get/set logging threshold for service 
 +  service-log-target SERVICE [TARGET] Get/set logging target for service 
 +  reset-failed [PATTERN...]           Reset failed state for all, one, or more 
 +                                      units 
 +Unit File Commands: 
 +  list-unit-files [PATTERN...]        List installed unit files 
 +  enable [UNIT...|PATH...]            Enable one or more unit files 
 +  disable UNIT...                     Disable one or more unit files 
 +  reenable UNIT...                    Reenable one or more unit files 
 +  preset UNIT...                      Enable/disable one or more unit files 
 +                                      based on preset configuration 
 +  preset-all                          Enable/disable all unit files based on 
 +                                      preset configuration 
 +  is-enabled UNIT...                  Check whether unit files are enabled 
 +  mask UNIT...                        Mask one or more units 
 +  unmask UNIT...                      Unmask one or more units 
 +  link PATH...                        Link one or more units files into 
 +                                      the search path 
 +  revert UNIT...                      Revert one or more unit files to vendor 
 +                                      version 
 +  add-wants TARGET UNIT...            Add 'Wants' dependency for the target 
 +                                      on specified one or more units 
 +lines 1-58 
 +[q] 
 +</code>
  
-Snapshot Commands: +====LAB #3 - Fichiers de Configuration====
-  snapshot [NAME]                 Create a snapshot +
-  delete [NAME...]                Remove one or more snapshots+
  
-Environment Commands: +===3.Fichiers de Configuration par Défaut===
-  show-environment                Dump environment +
-  set-environment [NAME=VALUE...] Set one or more environment variables +
-  unset-environment [NAME...]     Unset one or more environment variables+
  
-Manager Lifecycle Commands: +Les fichiers de configuration des Cibles et fichiers de configuration des Unités installés par des paquets se trouvent dans le répertoire **/lib/systemd/system** :
-  daemon-reload                   Reload systemd manager configuration +
-  daemon-reexec                   Reexecute systemd manager+
  
-System Commands: +<code> 
-  default                         Enter system default mode +root@debian11:~# pkg-config systemd --variable=systemdsystemunitdir 
-  rescue                          Enter system rescue mode +/lib/systemd/system
-  emergency                       Enter system emergency mode +
-  halt                            Shut down and halt the system +
-  poweroff                        Shut down and power-off the system +
-  reboot                          Shut down and reboot the system +
-  kexec                           Shut down and reboot the system with kexec +
-  exit                            Request user instance exit +
-  switch-root [ROOT] [INIT]       Change to a different root file system +
-  suspend                         Suspend the system +
-  hibernate                       Hibernate the system +
-  hybrid-sleep                    Hibernate and suspend the system +
-lines 95-123/123 (END)+
 </code> </code>
  
-====Fichiers de Configuration====+<code> 
 +root@debian11:~# ls -l /lib/systemd/system | more 
 +total 1076 
 +-rw-r--r-- 1 root root  576 Dec  7  2020 alsa-restore.service 
 +-rw-r--r-- 1 root root  528 Dec  7  2020 alsa-state.service 
 +lrwxrwxrwx 1 root root    9 Dec  7  2020 alsa-utils.service -> /dev/null 
 +-rw-r--r-- 1 root root  776 Feb  6  2021 anacron.service 
 +-rw-r--r-- 1 root root  154 Feb  6  2021 anacron.timer 
 +-rw-r--r-- 1 root root 1162 Apr  3  2021 apparmor.service 
 +-rw-r--r-- 1 root root  326 Jun 10  2021 apt-daily.service 
 +-rw-r--r-- 1 root root  156 Jun 10  2021 apt-daily.timer 
 +-rw-r--r-- 1 root root  389 Jun 10  2021 apt-daily-upgrade.service 
 +-rw-r--r-- 1 root root  184 Jun 10  2021 apt-daily-upgrade.timer 
 +-rw-r--r-- 1 root root 1491 Jan  6  2021 auditd.service 
 +lrwxrwxrwx 1 root root   14 Mar 20 20:55 autovt@.service -> getty@.service 
 +-rw-r--r-- 1 root root 1044 Feb  6  2021 avahi-daemon.service 
 +-rw-r--r-- 1 root root  870 Feb  6  2021 avahi-daemon.socket 
 +-rw-r--r-- 1 root root  927 Feb  2  2021 basic.target 
 +-rw-r--r-- 1 root root  380 Feb 22  2021 blk-availability.service 
 +-rw-r--r-- 1 root root  449 Feb  2  2021 blockdev@.target 
 +-rw-r--r-- 1 root root  427 Feb  2  2021 bluetooth.target 
 +-rw-r--r-- 1 root root  463 Feb  2  2021 boot-complete.target 
 +-rw-r--r-- 1 root root  295 Nov 12  2020 colord.service 
 +-rw-r--r-- 1 root root  150 Jan 13  2021 configure-printer@.service 
 +-rw-r--r-- 1 root root 1073 Mar 20 20:55 console-getty.service 
 +-rw-r--r-- 1 root root  312 Oct 29  2018 console-setup.service 
 +-rw-r--r-- 1 root root 1254 Mar 20 20:55 container-getty@.service 
 +-rw-r--r-- 1 root root  316 Feb 22  2021 cron.service 
 +lrwxrwxrwx 1 root root    9 Mar 20 20:55 cryptdisks-early.service -> /dev/null 
 +lrwxrwxrwx 1 root root    9 Mar 20 20:55 cryptdisks.service -> /dev/null 
 +-rw-r--r-- 1 root root  473 Feb  2  2021 cryptsetup-pre.target 
 +-rw-r--r-- 1 root root  420 Feb  2  2021 cryptsetup.target 
 +lrwxrwxrwx 1 root root   13 Mar 20 20:55 ctrl-alt-del.target -> reboot.target 
 +-rw-r--r-- 1 root root  234 Jan  7  2021 cups-browsed.service 
 +-rw-r--r-- 1 root root  142 May 27  2021 cups.path 
 +-rw-r--r-- 1 root root  278 May 27  2021 cups.service 
 +-rw-r--r-- 1 root root  132 May 27  2021 cups.socket 
 +lrwxrwxrwx 1 root root   25 Mar 20 20:55 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service 
 +lrwxrwxrwx 1 root root   23 Mar 20 20:55 dbus-org.freedesktop.locale1.service -> systemd-localed.service 
 +lrwxrwxrwx 1 root root   22 Mar 20 20:55 dbus-org.freedesktop.login1.service -> systemd-logind.service 
 +lrwxrwxrwx 1 root root   25 Mar 20 20:55 dbus-org.freedesktop.timedate1.service -> systemd-timedated.service 
 +-rw-r--r-- 1 root root  380 Feb 21  2021 dbus.service 
 +-rw-r--r-- 1 root root  102 Feb 21  2021 dbus.socket 
 +-rw-r--r-- 1 root root 1065 Mar 20 20:55 debug-shell.service 
 +lrwxrwxrwx 1 root root   16 Mar 20 20:55 default.target -> graphical.target 
 +-rw-r--r-- 1 root root  758 Feb  2  2021 dev-hugepages.mount 
 +-rw-r--r-- 1 root root  701 Feb  2  2021 dev-mqueue.mount 
 +-rw-r--r-- 1 root root  341 Feb 22  2021 dm-event.service 
 +-rw-r--r-- 1 root root  248 Feb 22  2021 dm-event.socket 
 +-rw-r--r-- 1 root root  297 Jun  7  2021 e2scrub_all.service 
 +-rw-r--r-- 1 root root  251 Jun  7  2021 e2scrub_all.timer 
 +-rw-r--r-- 1 root root  245 Jun  7  2021 e2scrub_fail@.service 
 +-rw-r--r-- 1 root root  550 Jun  7  2021 e2scrub_reap.service 
 +-rw-r--r-- 1 root root  438 Jun  7  2021 e2scrub@.service 
 +-rw-r--r-- 1 root root  805 Mar 20 20:55 emergency.service 
 +-rw-r--r-- 1 root root  479 Feb  2  2021 emergency.target 
 +-rw-r--r-- 1 root root  549 Feb  2  2021 exit.target 
 +-rw-r--r-- 1 root root  488 Feb  2  2021 final.target 
 +-rw-r--r-- 1 root root  461 Feb  2  2021 first-boot-complete.target 
 +-rw-r--r-- 1 root root  477 Jan 20 21:10 fstrim.service 
 +--More-- 
 +[q] 
 +</code>
  
-Les Cibles et les Unités sont configurées par des fichiers se trouvant dans le répertoire **/etc/systemd/system** :+===3.2 - Surchargement des Fichiers par Défaut=== 
 + 
 +Certains fichiers de configuration sont créés à la volée dans le répertoire **/run/systemd/system** lors du runtime puis ils sont détruits quand le système n'en a plus besoin :
  
 <code> <code>
-[root@centos7 ~]# ls -l /etc/systemd/system +root@debian11:~# ls -l /run/systemd/system/ 
-total 12 +total 0
-drwxr-xr-x. 2 root root   54 Mar  8 13:57 basic.target.wants +
-drwxr-xr-x. 2 root root   30 Mar  8 13:53 bluetooth.target.wants +
-lrwxrwxrwx. 1 root root   41 Mar  8 13:53 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service +
-lrwxrwxrwx. 1 root root   41 Mar  8 13:48 dbus-org.fedoraproject.FirewallD1.service -> /usr/lib/systemd/system/firewalld.service +
-lrwxrwxrwx. 1 root root   44 Mar  8 13:48 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service +
-lrwxrwxrwx. 1 root root   44 Mar  8 13:57 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service +
-lrwxrwxrwx. 1 root root   46 Mar  8 13:49 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service +
-lrwxrwxrwx. 1 root root   57 Mar  8 13:49 dbus-org.freedesktop.nm-dispatcher.service -> /usr/lib/systemd/system/NetworkManager-dispatcher.service +
-lrwxrwxrwx. 1 root root   36 Mar  8 14:05 default.target -> /lib/systemd/system/graphical.target +
-drwxr-xr-x. 2 root root   85 Mar  8 13:47 default.target.wants +
-lrwxrwxrwx. 1 root root   35 Mar  8 13:54 display-manager.service -> /usr/lib/systemd/system/gdm.service +
-drwxr-xr-x. 2 root root   31 Mar  8 13:47 getty.target.wants +
-drwxr-xr-x. 2 root root   63 Jun  4 14:59 graphical.target.wants +
-drwxr-xr-x. 2 root root 4096 Jun  4 10:00 multi-user.target.wants +
-drwxr-xr-x. 2 root root   29 Mar  8 13:48 nfs.target.wants +
-drwxr-xr-x. 2 root root   25 Mar  8 13:50 printer.target.wants +
-drwxr-xr-x. 2 root root   30 Jun  4 10:00 remote-fs.target.wants +
-drwxr-xr-x. 2 root root 4096 Mar  8 13:50 sockets.target.wants +
-drwxr-xr-x. 2 root root   35 Mar  8 13:57 spice-vdagentd.target.wants +
-drwxr-xr-x. 2 root root 4096 Mar  8 13:49 sysinit.target.wants +
-drwxr-xr-x. 2 root root   83 Mar  8 13:49 system-update.target.wants+
 </code> </code>
  
-ainsi que par des fichiers se trouvant dans le répertoire **/lib/systemd/system** et **/usr/lib/systemd/system** :+Les fichiers de configuration des Unités crées par les utilisateurs doivent être mis dans le répertoire **/usr/lib/systemd/user** :
  
 <code> <code>
-[root@centos7 ~]ls -/lib/systemd/system | more +root@debian11:~# pkg-config systemd --variable=systemduserunitdir 
-total 1208 +/usr/lib/systemd/user
--rw-r--r--. 1 root root  275 Mar 24 04:56 abrt-ccpp.service +
--rw-r--r--. 1 root root  380 Mar 24 04:56 abrtd.service +
--rw-r--r--. 1 root root  361 Mar 24 04:56 abrt-oops.service +
--rw-r--r--. 1 root root  266 Mar 24 04:56 abrt-pstoreoops.service +
--rw-r--r--. 1 root root  262 Mar 24 04:56 abrt-vmcore.service +
--rw-r--r--. 1 root root  311 Mar 24 04:56 abrt-xorg.service +
--rw-r--r--. 1 root root  421 Jun 10  2014 accounts-daemon.service +
--rw-r--r--. 1 root root  501 Mar  5 20:37 alsa-restore.service +
--rw-r--r--. 1 root root  558 Mar  5 20:37 alsa-state.service +
--rw-r--r--. 1 root root  412 Mar  5 20:37 alsa-store.service +
--rw-r--r--. 1 root root  645 Mar 26 11:43 anaconda-direct.service +
--rw-r--r--. 1 root root  185 Mar 26 11:43 anaconda-nm-config.service +
--rw-r--r--. 1 root root  660 Mar 26 11:43 anaconda-noshell.service +
--rw-r--r--. 1 root root  387 Mar 26 11:43 anaconda.service +
--rw-r--r--. 1 root root  684 Mar 26 11:43 anaconda-shell@.service +
--rw-r--r--. 1 root root  322 Mar 26 11:43 anaconda-sshd.service +
--rw-r--r--. 1 root root  312 Mar 26 11:43 anaconda.target +
-drwxr-xr-x. 2 root root 4096 Jun  4 15:33 anaconda.target.wants +
--rw-r--r--. 1 root root  498 Mar 26 11:43 anaconda-tmux@.service +
--rw-r--r--. 1 root root  275 Jun 10  2014 arp-ethers.service +
--rw-r--r--. 1 root root  205 Oct  7  2014 atd.service +
--rw-r-----. 1 root root  669 Mar  5 22:59 auditd.service +
--rw-r--r--. 1 root root  663 Mar  6 05:17 auth-rpcgss-module.service +
-lrwxrwxrwx. 1 root root   14 Jun  4 09:52 autovt@.service -> getty@.service +
--rw-r--r--. 1 root root 1044 Mar  5 23:03 avahi-daemon.service +
--rw-r--r--. 1 root root  874 Mar  5 23:03 avahi-daemon.socket +
--rw-r--r--. 1 root root  546 May 12 21:44 basic.target +
-drwxr-xr-x. 2 root root 4096 Jun  4 10:07 basic.target.wants +
---More--+
 </code> </code>
 +
 +<WRAP center round important 60%>
 +**Important** : De cette façon les fichiers dans **/usr/lib/systemd/user** surchargent les fichiers dans le répertoire **/run/systemd/system** qui surchargent les fichiers dans le répertoire **/lib/systemd/system**.
 +</WRAP>
 +
 +Les fichiers de configuration par défaut peuvent être surchargés par des fichiers dans d'autres répertoires :
  
 <code> <code>
-[root@centos7 ~]ls -/usr/lib/systemd/system | more +root@debian11:~# pkg-config systemd --variable=systemdsystemunitpath 
-total 1208 +/etc/systemd/system:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:/lib/systemd/system:/usr/lib/systemd/system:/lib/systemd/system
--rw-r--r--. 1 root root  275 Mar 24 04:56 abrt-ccpp.service +
--rw-r--r--. 1 root root  380 Mar 24 04:56 abrtd.service +
--rw-r--r--. 1 root root  361 Mar 24 04:56 abrt-oops.service +
--rw-r--r--. 1 root root  266 Mar 24 04:56 abrt-pstoreoops.service +
--rw-r--r--. 1 root root  262 Mar 24 04:56 abrt-vmcore.service +
--rw-r--r--. 1 root root  311 Mar 24 04:56 abrt-xorg.service +
--rw-r--r--. 1 root root  421 Jun 10  2014 accounts-daemon.service +
--rw-r--r--. 1 root root  501 Mar  5 20:37 alsa-restore.service +
--rw-r--r--. 1 root root  558 Mar  5 20:37 alsa-state.service +
--rw-r--r--. 1 root root  412 Mar  5 20:37 alsa-store.service +
--rw-r--r--. 1 root root  645 Mar 26 11:43 anaconda-direct.service +
--rw-r--r--. 1 root root  185 Mar 26 11:43 anaconda-nm-config.service +
--rw-r--r--. 1 root root  660 Mar 26 11:43 anaconda-noshell.service +
--rw-r--r--. 1 root root  387 Mar 26 11:43 anaconda.service +
--rw-r--r--. 1 root root  684 Mar 26 11:43 anaconda-shell@.service +
--rw-r--r--. 1 root root  322 Mar 26 11:43 anaconda-sshd.service +
--rw-r--r--. 1 root root  312 Mar 26 11:43 anaconda.target +
-drwxr-xr-x. 2 root root 4096 Jun  4 15:33 anaconda.target.wants +
--rw-r--r--. 1 root root  498 Mar 26 11:43 anaconda-tmux@.service +
--rw-r--r--. 1 root root  275 Jun 10  2014 arp-ethers.service +
--rw-r--r--. 1 root root  205 Oct  7  2014 atd.service +
--rw-r-----. 1 root root  669 Mar  5 22:59 auditd.service +
--rw-r--r--. 1 root root  663 Mar  6 05:17 auth-rpcgss-module.service +
-lrwxrwxrwx. 1 root root   14 Jun  4 09:52 autovt@.service -> getty@.service +
--rw-r--r--. 1 root root 1044 Mar  5 23:03 avahi-daemon.service +
--rw-r--r--. 1 root root  874 Mar  5 23:03 avahi-daemon.socket +
--rw-r--r--. 1 root root  546 May 12 21:44 basic.target +
-drwxr-xr-x. 2 root root 4096 Jun  4 10:07 basic.target.wants +
---More--+
 </code> </code>
  
-Par exemple, sous RHEL/CentOS 7, le service **sshd** est configuré par le fichier **/usr/lib/systemd/system/sshd.service** :+===3.3 - Les Fichiers d'Unités=== 
 + 
 +Prenons maintenant le cas du service **sshd** qui est configuré par le fichier **/usr/lib/systemd/system/ssh.service** :
  
 <code> <code>
-[root@centos7 ~]# cat /usr/lib/systemd/system/sshd.service+root@debian11:~# cat /lib/systemd/system/ssh.service
 [Unit] [Unit]
-Description=OpenSSH server daemon +Description=OpenBSD Secure Shell server 
-After=network.target sshd-keygen.service +Documentation=man:sshd(8) man:sshd_config(5) 
-Wants=sshd-keygen.service+After=network.target auditd.service 
 +ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
  
 [Service] [Service]
-EnvironmentFile=/etc/sysconfig/sshd +EnvironmentFile=-/etc/default/ssh 
-ExecStart=/usr/sbin/sshd -D $OPTIONS+ExecStartPre=/usr/sbin/sshd -t 
 +ExecStart=/usr/sbin/sshd -D $SSHD_OPTS 
 +ExecReload=/usr/sbin/sshd -t
 ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
 KillMode=process KillMode=process
 Restart=on-failure Restart=on-failure
-RestartSec=42s+RestartPreventExitStatus=255 
 +Type=notify 
 +RuntimeDirectory=sshd 
 +RuntimeDirectoryMode=0755
  
 [Install] [Install]
 WantedBy=multi-user.target WantedBy=multi-user.target
 +Alias=sshd.service
 </code> </code>
  
-Dans le fichier on peut noter la présence des lignes suivantes :+Dans le fichier on peut noter la présence des lignes suivantes dans la section **[Unit]** :
  
-  * **ExecStart=/usr/sbin/sshd -D $OPTIONS**, +  * **Description=OpenBSD Secure Shell server**, 
-     * Cette ligne définit l'exécutable à lancer+    * Cette directive est utilisée pour donner une courte description des fonctionnalités de l'Unité, 
-  * **After=network.target sshd-keygen.service**, +  * **Documentation=man:sshd(8) man:sshd_config(5)**, 
-    * Cette ligne indique les services qui devraient être démarrés avant le démarrage de sshd, +    * Cette directive stipule les chapitres des manuels et les URLs contenant de l'information en relation avec l'Unité
-  * **WantedBy=multi-user.target**, +  * **After=network.target auditd.service**, 
-    * Cette ligne indique la Cible dans laquelle le service doit être démarré,+    * Cette directive indique les cibles qui devraient être atteintes et les Unités qui devraient être démarrées avant l'Unité sshd. Par contre, cette directive ne spécifie pas une dépendance, 
 + 
 +Dans le fichier on peut aussi noter la présence des lignes suivantes dans la section **[Service]** : 
 + 
 +  * **Type=notify**, 
 +    * Cette directive indique que le service informera Systemd quand son démarrage a terminé, 
 +  * **ExecStart=/usr/sbin/sshd -D $SSHD_OPTS**, 
 +     * Cette directive définit l'exécutable à lancer
 +  * **ExecReload=/usr/sbin/sshd -t**, 
 +    * Cette directive indique la commande necéssaire pour redémarrer le service
 +  * **KillMode=process**, 
 +    * Cette directive indique comment les processus du service doivent être arrêtés. La valeur de **process** implique l'utilisation de SIGTERM suivi par SIGHUP,
   * **Restart=on-failure**,   * **Restart=on-failure**,
-    * Cette ligne indique quand le service doit être re-démarré.+    * Cette ligne indique que le service doit être re-démarré en cas d'arrêt de celui-ci.
  
-====Système de Démarrage====+On note la présence de la ligne suivante dans la section **[Install]** :
  
-**Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d'exécutionPour rendre la transition plus facile, il existe des **Cibles** qui simulent les niveaux d'exécution de **SysVinit** :+  * **WantedBy=multi-user.target**
 +    Cette directive indique la Cible dans laquelle le service doit être démarré. La présence de cette directive crée un lien symbolique dans le répertoire **/etc/systemd/system/multi-user.target.wants** qui pointe vers ce fichier.
  
-  * runlevel0.target, +<code> 
-  * runlevel1.target, +root@debian11:~# ls -l /etc/systemd/system/multi-user.target.wants 
-  * runlevel2.target, +total 0 
-  * runlevel3.target, +lrwxrwxrwx 1 root root 35 Apr 25 06:47 anacron.service -> /lib/systemd/system/anacron.service 
-  * runlevel4.target, +lrwxrwxrwx 1 root root 34 Apr 29 14:24 auditd.service -> /lib/systemd/system/auditd.service 
-  * runlevel5.target, +lrwxrwxrwx 1 root root 40 Apr 25 06:51 avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service 
-  * runlevel6.target.+lrwxrwxrwx 1 root root 41 Apr 25 06:32 console-setup.service -> /lib/systemd/system/console-setup.service 
 +lrwxrwxrwx 1 root root 32 Apr 25 06:31 cron.service -> /lib/systemd/system/cron.service 
 +lrwxrwxrwx 1 root root 40 Apr 25 06:52 cups-browsed.service -> /lib/systemd/system/cups-browsed.service 
 +lrwxrwxrwx 1 root root 29 Apr 25 06:52 cups.path -> /lib/systemd/system/cups.path 
 +lrwxrwxrwx 1 root root 38 Apr 25 06:51 lm-sensors.service -> /lib/systemd/system/lm-sensors.service 
 +lrwxrwxrwx 1 root root 40 Apr 25 06:52 ModemManager.service -> /lib/systemd/system/ModemManager.service 
 +lrwxrwxrwx 1 root root 38 Apr 25 06:31 networking.service -> /lib/systemd/system/networking.service 
 +lrwxrwxrwx 1 root root 42 Apr 25 06:52 NetworkManager.service -> /lib/systemd/system/NetworkManager.service 
 +lrwxrwxrwx 1 root root 36 Apr 25 06:30 remote-fs.target -> /lib/systemd/system/remote-fs.target 
 +lrwxrwxrwx 1 root root 33 Apr 28 13:36 rsync.service -> /lib/systemd/system/rsync.service 
 +lrwxrwxrwx 1 root root 35 Apr 25 06:31 rsyslog.service -> /lib/systemd/system/rsyslog.service 
 +lrwxrwxrwx 1 root root 31 Apr 25 07:04 ssh.service -> /lib/systemd/system/ssh.service 
 +lrwxrwxrwx 1 root root 42 Apr 25 06:51 wpa_supplicant.service -> /lib/systemd/system/wpa_supplicant.service 
 +</code>
  
-Ceci étant dans RHEL/CentOS 7 il y principalement deux Cibles finales :+Dernièrement, la ligne suivante de la section **[Install]** indique que le fichier ssh.service est référencé par un alias dénommé **sshd.service** :
  
-  * **multi-user.target** qui est l'équivalent du niveau d'exécution 3, +  * **Alias=sshd.service** 
-  * **graphical.target** qui est l'équivalent du niveau d'exécution 5.+ 
 +Les alias se trouvent dans la répertoire **/etc/systemd/system/** : 
 + 
 +<code> 
 +root@debian11:~# ls -l /etc/systemd/system/ 
 +total 36 
 +lrwxrwxrwx 1 root root   42 Apr 25 06:51 dbus-fi.w1.wpa_supplicant1.service -> /lib/systemd/system/wpa_supplicant.service 
 +lrwxrwxrwx 1 root root   40 Apr 25 06:51 dbus-org.freedesktop.Avahi.service -> /lib/systemd/system/avahi-daemon.service 
 +lrwxrwxrwx 1 root root   40 Apr 25 06:52 dbus-org.freedesktop.ModemManager1.service -> /lib/systemd/system/ModemManager.service 
 +lrwxrwxrwx 1 root root   53 Apr 25 06:52 dbus-org.freedesktop.nm-dispatcher.service -> /lib/systemd/system/NetworkManager-dispatcher.service 
 +lrwxrwxrwx 1 root root   45 Apr 25 06:48 dbus-org.freedesktop.timesync1.service -> /lib/systemd/system/systemd-timesyncd.service 
 +drwxr-xr-x 2 root root 4096 Apr 25 06:30 default.target.wants 
 +lrwxrwxrwx 1 root root   35 Apr 25 06:53 display-manager.service -> /lib/systemd/system/lightdm.service 
 +drwxr-xr-x 2 root root 4096 Apr 25 06:30 getty.target.wants 
 +drwxr-xr-x 2 root root 4096 Apr 25 06:50 graphical.target.wants 
 +drwxr-xr-x 2 root root 4096 Apr 29 14:24 multi-user.target.wants 
 +drwxr-xr-x 2 root root 4096 Apr 25 06:52 network-online.target.wants 
 +drwxr-xr-x 2 root root 4096 Apr 25 06:52 printer.target.wants 
 +drwxr-xr-x 2 root root 4096 Apr 26 13:47 sockets.target.wants 
 +lrwxrwxrwx 1 root root   31 Apr 25 07:04 sshd.service -> /lib/systemd/system/ssh.service 
 +drwxr-xr-x 2 root root 4096 Apr 26 13:47 sysinit.target.wants 
 +lrwxrwxrwx 1 root root   35 Apr 25 06:31 syslog.service -> /lib/systemd/system/rsyslog.service 
 +drwxr-xr-x 2 root root 4096 Apr 29 14:38 timers.target.wants 
 +</code> 
 + 
 +Pour consulter **l'ensemble** des directives de configuration ainsi que leurs valeurs d'une Unitéil convient d'utiliser la commande **systemctl show**  en spécifiant l'Unité concernée : 
 + 
 +<code> 
 +root@debian11:~# systemctl show sshd 
 +Type=notify 
 +Restart=on-failure 
 +NotifyAccess=main 
 +RestartUSec=100ms 
 +TimeoutStartUSec=1min 30s 
 +TimeoutStopUSec=1min 30s 
 +TimeoutAbortUSec=1min 30s 
 +TimeoutStartFailureMode=terminate 
 +TimeoutStopFailureMode=terminate 
 +RuntimeMaxUSec=infinity 
 +WatchdogUSec=0 
 +WatchdogTimestampMonotonic=0 
 +RootDirectoryStartOnly=no 
 +RemainAfterExit=no 
 +GuessMainPID=yes 
 +RestartPreventExitStatus=255 
 +MainPID=449 
 +ControlPID=0 
 +FileDescriptorStoreMax=0 
 +NFileDescriptorStore=0 
 +StatusErrno=0 
 +Result=success 
 +ReloadResult=success 
 +CleanResult=success 
 +UID=[not set] 
 +GID=[not set] 
 +NRestarts=0 
 +OOMPolicy=stop 
 +ExecMainStartTimestamp=Tue 2022-04-26 13:08:21 CEST 
 +ExecMainStartTimestampMonotonic=7283003 
 +ExecMainExitTimestampMonotonic=0 
 +ExecMainPID=449 
 +ExecMainCode=0 
 +ExecMainStatus=0 
 +ExecStartPre={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -t ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecStartPreEx={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -t ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecStart={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -D $SSHD_OPTS ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecStartEx={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -D $SSHD_OPTS ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecReload={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -t ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecReload={ path=/bin/kill ; argv[]=/bin/kill -HUP $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecReloadEx={ path=/usr/sbin/sshd ; argv[]=/usr/sbin/sshd -t ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +ExecReloadEx={ path=/bin/kill ; argv[]=/bin/kill -HUP $MAINPID ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 } 
 +Slice=system.slice 
 +ControlGroup=/system.slice/ssh.service 
 +MemoryCurrent=5832704 
 +CPUUsageNSec=664103000 
 +EffectiveCPUs= 
 +EffectiveMemoryNodes= 
 +TasksCurrent=1 
 +IPIngressBytes=[no data] 
 +IPIngressPackets=[no data] 
 +IPEgressBytes=[no data] 
 +IPEgressPackets=[no data] 
 +IOReadBytes=18446744073709551615 
 +IOReadOperations=18446744073709551615 
 +IOWriteBytes=18446744073709551615 
 +IOWriteOperations=18446744073709551615 
 +Delegate=no 
 +lines 1-58 
 +[q] 
 +</code> 
 + 
 +Pour consulter la liste des dépendances d'une Unité, il convient d'utiliser **systemctl list-dependancies** en spécifiant l'Unité concernée : 
 + 
 +<code> 
 +root@debian11:~# systemctl list-dependencies sshd.service 
 +sshd.service 
 +● ├─-.mount 
 +● ├─system.slice 
 +● └─sysinit.target 
 +●   ├─apparmor.service 
 +●   ├─blk-availability.service 
 +●   ├─dev-hugepages.mount 
 +●   ├─dev-mqueue.mount 
 +●   ├─keyboard-setup.service 
 +●   ├─kmod-static-nodes.service 
 +●   ├─lvm2-lvmpolld.socket 
 +●   ├─lvm2-monitor.service 
 +●   ├─plymouth-read-write.service 
 +●   ├─plymouth-start.service 
 +●   ├─proc-sys-fs-binfmt_misc.automount 
 +●   ├─sys-fs-fuse-connections.mount 
 +●   ├─sys-kernel-config.mount 
 +●   ├─sys-kernel-debug.mount 
 +●   ├─sys-kernel-tracing.mount 
 +●   ├─systemd-ask-password-console.path 
 +●   ├─systemd-binfmt.service 
 +●   ├─systemd-boot-system-token.service 
 +●   ├─systemd-hwdb-update.service 
 +●   ├─systemd-journal-flush.service 
 +●   ├─systemd-journald.service 
 +●   ├─systemd-machine-id-commit.service 
 +●   ├─systemd-modules-load.service 
 +●   ├─systemd-pstore.service 
 +●   ├─systemd-random-seed.service 
 +●   ├─systemd-sysctl.service 
 +●   ├─systemd-sysusers.service 
 +●   ├─systemd-timesyncd.service 
 +●   ├─systemd-tmpfiles-setup-dev.service 
 +●   ├─systemd-tmpfiles-setup.service 
 +●   ├─systemd-udev-trigger.service 
 +●   ├─systemd-udevd.service 
 +●   ├─systemd-update-utmp.service 
 +●   ├─cryptsetup.target 
 +●   │ └─systemd-cryptsetup@sdc11.service 
 +●   ├─local-fs.target 
 +●   │ ├─-.mount 
 +●   │ ├─mnt-sdc11.mount 
 +●   │ ├─systemd-fsck-root.service 
 +●   │ └─systemd-remount-fs.service 
 +●   └─swap.target 
 +●     └─dev-disk-by\x2duuid-1f9439f5\x2d4b19\x2d49b1\x2db292\x2d60c2c674cee9.swap 
 +</code> 
 + 
 +====LAB #4 - La Commande systemd-analyze==== 
 + 
 +Pour avoir une évaluation du temps de démarrage, il convient d'utiliser la commande suivante : 
 + 
 +<code> 
 +root@debian11:~# systemd-analyze 
 +Startup finished in 3.197s (kernel) + 4.577s (userspace) = 7.775s  
 +graphical.target reached after 4.567s in userspace 
 +</code> 
 + 
 +L'option **blame** de la commande systemd-analyze permet de voir le temps de démarrage de chaque Unité afin de pourvoir se concentrer sur les plus lentes : 
 + 
 +<code> 
 +root@debian11:~# systemd-analyze blame 
 +1.781s dev-sdb1.device 
 +1.645s man-db.service 
 +1.304s apparmor.service 
 +1.254s udisks2.service 
 +1.212s systemd-random-seed.service 
 +1.155s systemd-journal-flush.service 
 +1.027s NetworkManager-wait-online.service 
 +1.005s systemd-udevd.service 
 + 876ms ModemManager.service 
 + 645ms ssh.service 
 + 608ms NetworkManager.service 
 + 584ms polkit.service 
 + 542ms logrotate.service 
 + 469ms avahi-daemon.service 
 + 449ms wpa_supplicant.service 
 + 445ms systemd-logind.service 
 + 441ms lightdm.service 
 + 433ms plymouth-quit-wait.service 
 + 410ms user@113.service 
 + 372ms apt-daily.service 
 + 358ms apt-daily-upgrade.service 
 + 329ms packagekit.service 
 + 313ms keyboard-setup.service 
 + 299ms networking.service 
 + 288ms systemd-timesyncd.service 
 + 226ms systemd-tmpfiles-setup.service 
 + 197ms systemd-modules-load.service 
 + 196ms rsyslog.service 
 + 184ms systemd-udev-trigger.service 
 + 165ms e2scrub_reap.service 
 + 164ms systemd-journald.service 
 + 152ms user@1000.service 
 + 108ms hddtemp.service 
 + 101ms systemd-tmpfiles-setup-dev.service 
 +  94ms systemd-sysusers.service 
 +  93ms plymouth-start.service 
 +  91ms lvm2-pvscan@8:41.service 
 +  89ms systemd-update-utmp.service 
 +  86ms systemd-remount-fs.service 
 +  80ms lm-sensors.service 
 +  72ms lvm2-pvscan@8:39.service 
 +  68ms systemd-sysctl.service 
 +  67ms plymouth-read-write.service 
 +  65ms lvm2-monitor.service 
 +  63ms dev-hugepages.mount 
 +  63ms sys-kernel-debug.mount 
 +  62ms dev-mqueue.mount 
 +  60ms sys-kernel-tracing.mount 
 +  57ms lvm2-pvscan@8:38.service 
 +  41ms systemd-user-sessions.service 
 +  33ms modprobe@fuse.service 
 +  32ms sys-kernel-config.mount 
 +  32ms ifupdown-pre.service 
 +  27ms auditd.service 
 +  27ms console-setup.service 
 +  22ms rtkit-daemon.service 
 +  20ms modprobe@configfs.service 
 +  19ms sys-fs-fuse-connections.mount 
 +lines 1-58 
 +[q] 
 +</code> 
 + 
 +L'option **critical-chain** de la commande **systemd-analyze** permet de voir l'enchaînement des événements qui amènent au chargement de l'Unité qui est passée en argument : 
 + 
 +<code> 
 +root@debian11:~# systemd-analyze critical-chain sshd.service 
 +The time when unit became active or started is printed after the "@" character. 
 +The time the unit took to start is printed after the "+" character. 
 + 
 +ssh.service +645ms 
 +└─network.target @3.425s 
 +  └─NetworkManager.service @2.816s +608ms 
 +    └─dbus.service @2.812s 
 +      └─basic.target @2.789s 
 +        └─sockets.target @2.789s 
 +          └─dbus.socket @2.789s 
 +            └─sysinit.target @2.786s 
 +              └─systemd-timesyncd.service @2.497s +288ms 
 +                └─systemd-tmpfiles-setup.service @2.268s +226ms 
 +                  └─systemd-journal-flush.service @1.112s +1.155s 
 +                    └─systemd-journald.service @946ms +164ms 
 +                      └─systemd-journald.socket @925ms 
 +                        └─system.slice @487ms 
 +                          └─-.slice @487ms 
 +</code> 
 + 
 +Les options de la commande **systemd-analyze** sont : 
 + 
 +<code> 
 +root@debian11:~# systemd-analyze --help 
 +systemd-analyze [OPTIONS...] COMMAND ... 
 + 
 +Profile systemd, show unit dependencies, check unit files. 
 + 
 +Commands: 
 +  [time]                   Print time required to boot the machine 
 +  blame                    Print list of running units ordered by time to init 
 +  critical-chain [UNIT...] Print a tree of the time critical chain of units 
 +  plot                     Output SVG graphic showing service initialization 
 +  dot [UNIT...]            Output dependency graph in dot(1) format 
 +  dump                     Output state serialization of service manager 
 +  cat-config               Show configuration file and drop-ins 
 +  unit-files               List files and symlinks for units 
 +  unit-paths               List load directories for units 
 +  exit-status [STATUS...]  List exit status definitions 
 +  capability [CAP...]      List capability definitions 
 +  syscall-filter [NAME...] Print list of syscalls in seccomp filter 
 +  condition CONDITION...   Evaluate conditions and asserts 
 +  verify FILE...           Check unit files for correctness 
 +  calendar SPEC...         Validate repetitive calendar time events 
 +  timestamp TIMESTAMP...   Validate a timestamp 
 +  timespan SPAN...         Validate a time span 
 +  security [UNIT...]       Analyze security of unit 
 + 
 +Options: 
 +  -h --help                Show this help 
 +     --version             Show package version 
 +     --no-pager            Do not pipe output into a pager 
 +     --system              Operate on system systemd instance 
 +     --user                Operate on user systemd instance 
 +     --global              Operate on global user configuration 
 +  -H --host=[USER@]HOST    Operate on remote host 
 +  -M --machine=CONTAINER   Operate on local container 
 +     --order               Show only order in the graph 
 +     --require             Show only requirement in the graph 
 +     --from-pattern=GLOB   Show only origins in the graph 
 +     --to-pattern=GLOB     Show only destinations in the graph 
 +     --fuzz=SECONDS        Also print services which finished SECONDS earlier 
 +                           than the latest in the branch 
 +     --man[=BOOL]          Do [not] check for existence of man pages 
 +     --generators[=BOOL]   Do [not] run unit generators (requires privileges) 
 +     --iterations=N        Show the specified number of iterations 
 +     --base-time=TIMESTAMP Calculate calendar times relative to specified time 
 + 
 +See the systemd-analyze(1) man page for details. 
 +</code> 
 + 
 +====LAB #5 - Les Cibles====
  
 Chaque Cible est décrite par un fichier de configuration : Chaque Cible est décrite par un fichier de configuration :
  
 <code> <code>
-[root@centos7 ~]# cat /usr/lib/systemd/system/graphical.target+root@debian11:~# cat /usr/lib/systemd/system/graphical.target 
 +#  SPDX-License-Identifier: LGPL-2.1-or-later 
 +#
 #  This file is part of systemd. #  This file is part of systemd.
 # #
Ligne 3516: Ligne 3725:
 Documentation=man:systemd.special(7) Documentation=man:systemd.special(7)
 Requires=multi-user.target Requires=multi-user.target
-After=multi-user.target 
-Conflicts=rescue.target 
 Wants=display-manager.service Wants=display-manager.service
 +Conflicts=rescue.service rescue.target
 +After=multi-user.target rescue.service rescue.target display-manager.service
 AllowIsolate=yes AllowIsolate=yes
- 
-[Install] 
-Alias=default.target 
 </code> </code>
  
Ligne 3528: Ligne 3734:
  
   * **Requires=multi-user.target**,   * **Requires=multi-user.target**,
-     * Cette ligne indique que le **graphical.target** ne peut pas être atteint si le **multi-user.target** n'a pas été atteint aupréalable+     * Cette ligne indique que le **graphical.target** ne peut pas être atteint si le **multi-user.target** n'a pas été atteint au préalable
-  * **After=multi-user.target**, +  * **After=multi-user.target rescue.service rescue.target display-manager.service**, 
-    * Cette ligne indique le **multi-user.target** doit d'abord être lancé+    * Cette ligne indique le **multi-user.target** et **rescue.target** doivent d'abord être atteints et que les services **rescue.service** et **display-manager.service** doivent d'abord être démarrés
-  * **Conflicts=rescue.target**, +  * **Conflicts=rescue.service rescue.target**, 
-    * Cette ligne indique la Cible en conflit avec le **graphical.target**,+    * Cette ligne indique la Cible et le service en conflits avec le **graphical.target**,
   * **Wants=display-manager.service**,   * **Wants=display-manager.service**,
     * Cette ligne indique quel service doit être démarré.     * Cette ligne indique quel service doit être démarré.
  
-Dernièrement, sous RHEL/CentOS 7, la Cible par défaut peut être modifiée en éditant le lien symbolique **/etc/systemd/system/default.target** :+===5.1 - Contrôler les dépendances d'une Cible=== 
 + 
 +Les dépendances d'une Cible peuvent être consultées en utilisant la commande **systemctl list-dependencies** :
  
 <code> <code>
-[root@centos7 ~]ls -l /etc/systemd/system/default.target +root@debian11:~# systemctl list-dependencies multi-user.target 
-lrwxrwxrwx1 root root 36 Mar  8 14:05 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target+multi-user.target 
 +● ├─anacron.service 
 +● ├─auditd.service 
 +● ├─avahi-daemon.service 
 +● ├─console-setup.service 
 +● ├─cron.service 
 +● ├─cups-browsed.service 
 +● ├─cups.path 
 +● ├─dbus.service 
 +● ├─hddtemp.service 
 +● ├─lm-sensors.service 
 +● ├─ModemManager.service 
 +● ├─networking.service 
 +● ├─NetworkManager.service 
 +● ├─plymouth-quit-wait.service 
 +● ├─plymouth-quit.service 
 +● ├─rsync.service 
 +● ├─rsyslog.service 
 +● ├─ssh.service 
 +● ├─systemd-ask-password-wall.path 
 +● ├─systemd-logind.service 
 +● ├─systemd-update-utmp-runlevel.service 
 +● ├─systemd-user-sessions.service 
 +● ├─wpa_supplicant.service 
 +● ├─basic.target 
 +● │ ├─-.mount 
 +● │ ├─tmp.mount 
 +● │ ├─paths.target 
 +● │ ├─slices.target 
 +● │ │ ├─-.slice 
 +● │ │ └─system.slice 
 +● │ ├─sockets.target 
 +● │ │ ├─avahi-daemon.socket 
 +● │ │ ├─cups.socket 
 +● │ │ ├─dbus.socket 
 +● │ │ ├─dm-event.socket 
 +● │ │ ├─systemd-initctl.socket 
 +● │ │ ├─systemd-journald-audit.socket 
 +● │ │ ├─systemd-journald-dev-log.socket 
 +● │ │ ├─systemd-journald.socket 
 +● │ │ ├─systemd-udevd-control.socket 
 +● │ │ └─systemd-udevd-kernel.socket 
 +● │ ├─sysinit.target 
 +● │ │ ├─apparmor.service 
 +● │ │ ├─blk-availability.service 
 +● │ │ ├─dev-hugepages.mount 
 +● │ │ ├─dev-mqueue.mount 
 +● │ │ ├─keyboard-setup.service 
 +● │ │ ├─kmod-static-nodes.service 
 +● │ │ ├─lvm2-lvmpolld.socket 
 +● │ │ ├─lvm2-monitor.service 
 +● │ │ ├─plymouth-read-write.service 
 +● │ │ ├─plymouth-start.service 
 +● │ │ ├─proc-sys-fs-binfmt_misc.automount 
 +● │ │ ├─sys-fs-fuse-connections.mount 
 +● │ │ ├─sys-kernel-config.mount 
 +● │ │ ├─sys-kernel-debug.mount 
 +● │ │ ├─sys-kernel-tracing.mount 
 +lines 1-58 
 +[q]
 </code> </code>
  
-====La Commande systemd-analyze====+Les points noirs au début de chaque ligne dans la sortie ci-dessus peuvent être de trois couleurs différentes :
  
-Pour avoir une évaluation du temps de démarrageil convient d'utiliser la commande suivante :+  * **Vert** implique que le servicela cible ou l'unité est activé et démarré.  
 +  * **Blanc** implique le service, la cible ou l'unité est inactif. 
 +  * **Rouge** implique que le service, la cible ou l'unité n'a pas démarré à cause d'une erreur fatale. 
 + 
 +Pour visualiser les Unités en état d'erreur fatale, utilisez la commande **systemctl --failed** :
  
 <code> <code>
-[root@centos7 ~]systemd-analyze +root@debian11:~# systemctl --failed 
-Startup finished in 769ms (kernel) + 4.643s (initrd) + 40.147s (userspace) = 45.560s+  UNIT LOAD ACTIVE SUB DESCRIPTION 
 +0 loaded units listed.
 </code> </code>
  
-L'option **blame** de la commande systemd-analyze permet de voir le temps de démarrage de chaque Unité afin de pourvoir se concentrer sur les plus lentes :+Les dépendances sont créés sous la forme de liens symboliques dans les répertoires **/etc/systemd/system/multi-user.target.wants** et **/usr/lib/systemd/system/multi-user.target.wants** :
  
 <code> <code>
-[root@centos7 ~]# systemd-analyze blame +root@debian11:~# ls -l /etc/systemd/system/multi-user.target.wants 
-         12.274s firewalld.service +total 0 
-         10.302s tuned.service +lrwxrwxrwx 1 root root 35 Apr 25 06:47 anacron.service -> /lib/systemd/system/anacron.service 
-          9.676s accounts-daemon.service +lrwxrwxrwx 1 root root 34 Apr 29 14:24 auditd.service -> /lib/systemd/system/auditd.service 
-          8.875s gssproxy.service +lrwxrwxrwx 1 root root 40 Apr 25 06:51 avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service 
-          8.860s ModemManager.service +lrwxrwxrwx 1 root root 41 Apr 25 06:32 console-setup.service -> /lib/systemd/system/console-setup.service 
-          8.598s vboxadd-x11.service +lrwxrwxrwx 1 root root 32 Apr 25 06:31 cron.service -> /lib/systemd/system/cron.service 
-          7.829s kdump.service +lrwxrwxrwx 1 root root 40 Apr 25 06:52 cups-browsed.service -> /lib/systemd/system/cups-browsed.service 
-          7.089s vboxadd.service +lrwxrwxrwx 1 root root 29 Apr 25 06:52 cups.path -> /lib/systemd/system/cups.path 
-          6.398s plymouth-quit-wait.service +lrwxrwxrwx 1 root root 38 Apr 25 06:51 lm-sensors.service -> /lib/systemd/system/lm-sensors.service 
-          5.593s NetworkManager-wait-online.service +lrwxrwxrwx 1 root root 40 Apr 25 06:52 ModemManager.service -> /lib/systemd/system/ModemManager.service 
-          5.379s avahi-daemon.service +lrwxrwxrwx root root 38 Apr 25 06:31 networking.service -> /lib/systemd/system/networking.service 
-          5.104s abrt-ccpp.service +lrwxrwxrwx root root 42 Apr 25 06:52 NetworkManager.service -> /lib/systemd/system/NetworkManager.service 
-          5.065s postfix.service +lrwxrwxrwx root root 36 Apr 25 06:30 remote-fs.target -> /lib/systemd/system/remote-fs.target 
-          4.684s systemd-logind.service +lrwxrwxrwx root root 33 Apr 28 13:36 rsync.service -> /lib/systemd/system/rsync.service 
-          4.385s sysstat.service +lrwxrwxrwx 1 root root 35 Apr 25 06:31 rsyslog.service -> /lib/systemd/system/rsyslog.service 
-          4.306s rtkit-daemon.service +lrwxrwxrwx 1 root root 31 Apr 25 07:04 ssh.service -> /lib/systemd/system/ssh.service 
-          3.927s systemd-udev-settle.service +lrwxrwxrwx 1 root root 42 Apr 25 06:51 wpa_supplicant.service -> /lib/systemd/system/wpa_supplicant.service 
-          3.396s ksmtuned.service + 
-          3.084s rhel-dmesg.service +root@debian11:~# ls -l /usr/lib/systemd/system/multi-user.target.wants 
-          2.811s libvirtd.service +total 0 
-          2.428s chronyd.service +lrwxrwxrwx 1 root root 15 Feb 21  2021 dbus.service -../dbus.service 
-          2.401s vboxadd-service.service +lrwxrwxrwx 1 root root 15 Mar 20 20:55 getty.target -../getty.target 
-          2.349s nfs-config.service +lrwxrwxrwx 1 root root 24 Mar  2  2021 plymouth-quit.service -../plymouth-quit.service 
-          2.266s var-lib-nfs-rpc_pipefs.mount +lrwxrwxrwx 1 root root 29 Mar  2  2021 plymouth-quit-wait.service -../plymouth-quit-wait.service 
-          2.229s rhel-loadmodules.service +lrwxrwxrwx 1 root root 33 Mar 20 20:55 systemd-ask-password-wall.path -> ../systemd-ask-password-wall.path 
-          2.104s rsyslog.service +lrwxrwxrwx 1 root root 25 Mar 20 20:55 systemd-logind.service -../systemd-logind.service 
-          1.357s network.service +lrwxrwxrwx 1 root root 39 Mar 20 20:55 systemd-update-utmp-runlevel.service -../systemd-update-utmp-runlevel.service 
-          1.283s lvm2-monitor.service +lrwxrwxrwx 1 root root 32 Mar 20 20:55 systemd-user-sessions.service -../systemd-user-sessions.service
-          1.246s rpcbind.service +
-          1.069s systemd-fsck-root.service +
-          1.007s colord.service +
-           944ms systemd-tmpfiles-setup-dev.service +
-           872ms systemd-tmpfiles-clean.service +
-           791ms rhel-readonly.service +
-           780ms NetworkManager.service +
-           743ms dmraid-activation.service +
-           723ms gdm.service +
-           720ms ksm.service +
-           718ms polkit.service +
-           716ms proc-fs-nfsd.mount +
-           669ms auditd.service +
-           660ms boot.mount +
-           608ms systemd-udev-trigger.service +
-           601ms kmod-static-nodes.service +
-           565ms netcf-transaction.service +
-           520ms systemd-vconsole-setup.service +
-           497ms systemd-sysctl.service +
-           487ms sys-kernel-debug.mount +
-           302ms dev-disk-by\x2duuid-11a4d11d\x2d81e4\x2d46a7\x2d82e0\x2d7796cd597dc9.swap +
-           297ms systemd-tmpfiles-setup.service +
-           283ms dev-mqueue.mount +
-           282ms dev-hugepages.mount +
-           261ms rhel-import-state.service +
-           243ms udisks2.service +
-           239ms systemd-user-sessions.service +
-           235ms rpc-statd-notify.service +
-           217ms systemd-random-seed.service +
-           173ms plymouth-read-write.service +
-           161ms systemd-udevd.service +
-           147ms upower.service +
-           142ms systemd-fsck@dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.service +
-           110ms plymouth-start.service +
-            96ms sys-fs-fuse-connections.mount +
-            82ms bluetooth.service +
-            73ms iscsi-shutdown.service +
-            69ms systemd-remount-fs.service +
-            63ms systemd-hostnamed.service +
-            53ms systemd-update-utmp.service +
-            38ms systemd-journal-flush.service +
-            33ms sys-kernel-config.mount +
-            31ms systemd-update-utmp-runlevel.service +
-lines 43-71/71 (END)+
 </code> </code>
  
-L'option **critical-chain** permet de voir l'enchaînement des événements qui amènent au chargement de l'Unité passée en argument :+===5.2 - La Cible par Défaut=== 
 + 
 +==Consulter la Cible par Défaut== 
 + 
 +Pour consulter la cible par défaut, il convient d'utiliser la commande **systemctl get-default** :
  
 <code> <code>
-[root@centos7 ~]systemd-analyze critical-chain sshd.service +root@debian11:~# systemctl get-default 
-The time after the unit is active or started is printed after the "@" character+graphical.target 
-The time the unit takes to start is printed after the "+" character.+</code>
  
-sshd.service @32.037s +==Modifier la Cible par Défaut== 
-└─network.target @31.990s + 
-  └─network.service @30.621s +1.357s +Pour modifier la Cible par défaut avec une prise en compte lors du **prochain** démarrage, il convient d'utiliser la commande **systemctl set-default** : 
-    └─NetworkManager.service @24.242s +780ms + 
-      └─firewalld.service @11.954s +12.274s +<code> 
-        └─basic.target @11.937s +root@debian11:~# ls -l /lib/systemd/system/multi-user.target 
-          └─sockets.target @11.937s +-rw-r--r-- 1 root root 540 Feb  2  2021 /lib/systemd/system/multi-user.target 
-            └─dbus.socket @11.936s +root@debian11:~# systemctl set-default multi-user.target 
-              └─sysinit.target @11.784s +Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target.
-                └─systemd-update-utmp.service @11.726s +53ms +
-                  └─auditd.service @11.051s +669ms +
-                    └─systemd-tmpfiles-setup.service @10.734s +297ms +
-                      └─rhel-import-state.service @10.470s +261ms +
-                        └─local-fs.target @10.464s +
-                          └─boot.mount @9.798s +660ms +
-                            └─systemd-fsck@dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.service @9.654s +142ms +
-                              └─dev-disk-by\x2duuid-e8d3bd48\x2d1386\x2d411c\x2d9675\x2d41c3f8f1a309.device @9.650s+
 </code> </code>
  
-===Options de la Commande===+==Modifier la Cible en Cours==
  
-Les options de la commande **systemd-analyze** sont :+Il est possible de modifier la cible actuellement en cours en utilisant la commande **systemctl isolate** :
  
 <code> <code>
-[root@centos7 ~]systemd-analyze --help +root@debian11:~# systemctl isolate rescue
-systemd-analyze [OPTIONS...] {COMMAND} ...+
  
-Process systemd profiling information+root@debian11:~# systemctl list-units --type target | egrep "eme|res|gra|mul" | head -1 
 +  rescue.target                    loaded active active Rescue Mode
  
-  -h --help           Show this help +root@debian11:~# runlevel 
-     --version        Show package version +5 1
-     --system         Connect to system manager +
-     --user           Connect to user service manager +
-     --order          When generating a dependency graph, show only order +
-     --require        When generating a dependency graph, show only requirement +
-     --from-pattern=GLOB, --to-pattern=GLOB +
-                      When generating a dependency graph, filter only origins +
-                      or destinations, respectively +
-     --fuzz=TIMESPAN  When printing the tree of the critical chain, print also +
-                      services, which finished TIMESPAN earlier, than the +
-                      latest in the branch. The unit of TIMESPAN is seconds +
-                      unless specified with a different unit, i.e. 50ms +
-     --no-pager       Do not pipe output into a pager+
  
-Commands+root@debian11:~# who -r 
-  time                Print time spent in the kernel before reaching userspace +         run-level 1  2022-04-30 12:19                   last=5 
-  blame               Print list of running units ordered by time to init + 
-  critical-chain      Print a tree of the time critical chain of units +root@debian11:~# systemctl isolate multi-user 
-  plot                Output SVG graphic showing service initialization + 
-  dot                 Output dependency graph in dot(1) format +root@debian11:~# systemctl list-units --type target | egrep "eme|res|gra|mul" | head -1 
-  set-log-level LEVEL Set logging threshold for systemd +  multi-user.target                loaded active active Multi-User System 
-  dump                Output state serialization of service manager+ 
 +root@debian11:~# runlevel 
 +3 
 + 
 +root@debian11:~# who -
 +         run-level  2022-04-30 12:21                   last=1
 </code> </code>
  
-====Gestion des Services====+====LAB #6 - Gestion des Services====
  
-Pour obtenir le détail sur un service donné, il convient d'utiliser la commande **systemctl** :+===6.1 - Gestion des Instances Uniques=== 
 + 
 +Commencez par installer le paquet **httpd** :
  
 <code> <code>
-[root@centos7 ~]# systemctl status sshd.service +root@debian11:~# apt install -y apache2 
-sshd.service - OpenSSH server daemon +</code> 
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) + 
-   Active: active (running) since Thu 2015-06-11 11:01:52 CEST; 2h 45min ago +Pour obtenir le détail sur un service donné, il convient d'utiliser la commande **systemctl status** : 
- Main PID: 1212 (sshd+ 
-   CGroup: /system.slice/sshd.service +<code> 
-           └─1212 /usr/sbin/sshd -D+root@debian11:~# systemctl status apache2.service 
 +● apache2.service - The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) 
 +     Active: active (running) since Sat 2022-04-30 12:22:50 CEST; 42s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +   Main PID: 56037 (apache2
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.8M 
 +        CPU: 38ms 
 +     CGroup: /system.slice/apache2.service 
 +             ├─56037 /usr/sbin/apache2 -k start 
 +             ├─56039 /usr/sbin/apache2 -k start 
 +             └─56040 /usr/sbin/apache2 -k start
  
-Jun 11 11:01:52 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. +Apr 30 12:22:50 debian11 systemd[1]: Starting The Apache HTTP Server... 
-Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on 0.0.0.0 port 22+Apr 30 12:22:50 debian11 systemd[1]: Started The Apache HTTP Server.
-Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]: Server listening on :: port 22.+
 </code> </code>
  
-Pour arrêter une Unité de service, utilisez la commande suivante :+Dans le cas du service apache2 ci-dessus, on peut constater que le statut est **enabled**. Le statut peut être une de 2 valeurs : 
 + 
 +  * **disabled** - le service ne démarrera pas lors du prochain démarrage du système. 
 +  * **enabled** - le service démarrera lors du prochain démarrage du système. 
 + 
 +Il est possible de vérifier le statut en utilisant le commande **systemctl is-enabled** :
  
 <code> <code>
-[root@centos7 ~]# systemctl stop sshd.service +root@debian11:~# systemctl is-enabled apache2.service 
-[root@centos7 ~]# systemctl status sshd.service +enabled 
-sshd.service - OpenSSH server daemon +</code>
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) +
-   Active: inactive (dead) since Thu 2015-06-11 13:58:59 CEST; 16s ago +
-  Process: 1212 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS) +
- Main PID: 1212 (code=exited, status=0/SUCCESS)+
  
-Jun 11 11:01:52 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon+Pour rendre le statut **disabled**, il convient d'utiliser la commande **systemctl enable** : 
-Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]Server listening on 0.0.0.0 port 22+ 
-Jun 11 11:01:53 centos7.fenestros.loc sshd[1212]Server listening on :: port 22+<code> 
-Jun 11 13:58:59 centos7.fenestros.loc systemd[1]: Stopping OpenSSH server daemon... +root@debian11:~# systemctl disable apache2.service 
-Jun 11 13:58:59 centos7.fenestros.loc sshd[1212]: Received signal 15; terminating. +Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install
-Jun 11 13:58:59 centos7.fenestros.loc systemd[1]: Stopped OpenSSH server daemon.+Executing/lib/systemd/systemd-sysv-install disable apache2 
 +Removed /etc/systemd/system/multi-user.target.wants/apache2.service. 
 + 
 +root@debian11:~# systemctl is-enabled apache2.service 
 +disabled 
 + 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service - The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled) 
 +     Activeactive (running) since Sat 2022-04-30 12:22:50 CEST; 3min 6s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +   Main PID56037 (apache2) 
 +      Tasks55 (limit4663) 
 +     Memory: 8.8M 
 +        CPU46ms 
 +     CGroup/system.slice/apache2.service 
 +             ├─56037 /usr/sbin/apache2 -k start 
 +             ├─56039 /usr/sbin/apache2 -k start 
 +             └─56040 /usr/sbin/apache2 -k start 
 + 
 +Apr 30 12:22:50 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 12:22:50 debian11 systemd[1]: Started The Apache HTTP Server.
 </code> </code>
  
-Pour démarrer un service, utilisez la commande suivante :+Dans le cas du service httpd ci-dessuson peut constater que l'état est **active (running)**.  L'état peut être une de 7 valeurs : 
 + 
 +  * **inactive (dead)** - le service est arrêté. 
 +  * **active(running** - le service est démarré avec un ou plusieurs processus. 
 +  * **active(exited)** - le service a terminé une configuration unique. 
 +  * **active(waiting)** - le service est démarré mais en attente d'un évènement. 
 +  * **activating** - le service est en cours d'activation. 
 +  * **deactivating** - le service est en cours de désactivation. 
 +  * **failed** - le service a rencontré une erreur fatale. 
 + 
 +Il est possible de vérifier l'état en utilisant le commande **systemctl is-active** :
  
 <code> <code>
-[root@centos7 ~]# systemctl start ssh.service +root@debian11:~# systemctl is-active apache2.service 
-[root@centos7 ~]# systemctl status sshd.service +active 
-sshd.service OpenSSH server daemon +</code>
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) +
-   Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 6s ago +
- Main PID: 6624 (sshd) +
-   CGroup: /system.slice/sshd.service +
-           └─6624 /usr/sbin/sshd -D+
  
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... +Pour rendre l'état **inactive(dead)**, utilisez la commande suivante 
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon. + 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22. +<code> 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :port 22.+root@debian11:~# systemctl stop apache2.service
 </code> </code>
  
-Pour désactiver un service au prochain démarrage du système, utilisez l'option **disable** :+Vérifiez ensuite l'état du service :
  
 <code> <code>
-[root@centos7 ~]# systemctl disable sshd.service +root@debian11:~# systemctl is-active apache2.service 
-rm '/etc/systemd/system/multi-user.target.wants/sshd.service' +inactive
-[root@centos7 ~]# systemctl status sshd.service +
-sshd.service - OpenSSH server daemon +
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled) +
-   Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 1min 59s ago +
- Main PID: 6624 (sshd) +
-   CGroup: /system.slice/sshd.service +
-           └─6624 /usr/sbin/sshd -D+
  
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Starting OpenSSH server daemon... +root@debian11:~# systemctl status apache2.service 
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]: Started OpenSSH server daemon+● apache2.service - The Apache HTTP Server 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22+     Loadedloaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled) 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22.+     Active: inactive (dead) since Sat 2022-04-30 12:27:53 CEST; 1min 26s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +    Process: 56435 ExecStop=/usr/sbin/apachectl graceful-stop (code=exited, status=0/SUCCESS) 
 +   Main PID: 56037 (code=exited, status=0/SUCCESS) 
 +        CPU: 77ms 
 + 
 +Apr 30 12:22:50 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 12:22:50 debian11 systemd[1]: Started The Apache HTTP Server
 +Apr 30 12:27:53 debian11 systemd[1]: Stopping The Apache HTTP Server... 
 +Apr 30 12:27:53 debian11 systemd[1]: apache2.service: Succeeded. 
 +Apr 30 12:27:53 debian11 systemd[1]: Stopped The Apache HTTP Server.
 </code> </code>
  
-Pour activer un service au prochain démarrage du système, utilisez l'option **enable** :+Pour démarrer une Unité de service, utilisez la commande suivante :
  
 <code> <code>
-[root@centos7 ~]# systemctl enable sshd.service +root@debian11:~# systemctl start apache2.service
-ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service' +
-[root@centos7 ~]# systemctl status sshd.service +
-sshd.service - OpenSSH server daemon +
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) +
-   Active: active (running) since Thu 2015-06-11 14:00:17 CEST; 3min 27s ago +
- Main PID: 6624 (sshd) +
-   CGroup: /system.slice/sshd.service +
-           └─6624 /usr/sbin/sshd -D+
  
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]Starting OpenSSH server daemon..+root@debian11:~# systemctl status apache2.service 
-Jun 11 14:00:17 centos7.fenestros.loc systemd[1]Started OpenSSH server daemon+● apache2.service - The Apache HTTP Server 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on 0.0.0.0 port 22+     Loadedloaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled) 
-Jun 11 14:00:17 centos7.fenestros.loc sshd[6624]: Server listening on :: port 22.+     Activeactive (running) since Sat 2022-04-30 12:30:17 CEST; 2s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +    Process56448 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) 
 +   Main PID: 56452 (apache2) 
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.7M 
 +        CPU35ms 
 +     CGroup/system.slice/apache2.service 
 +             ├─56452 /usr/sbin/apache2 -k start 
 +             ├─56453 /usr/sbin/apache2 -k start 
 +             └─56454 /usr/sbin/apache2 -k start 
 + 
 +Apr 30 12:30:17 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 12:30:17 debian11 systemd[1]: Started The Apache HTTP Server.
 </code> </code>
  
-=====Arrêt du Système=====+Pour activer un service au prochain démarrage du système, utilisez l'option **enable** :
  
-====La Commande shutdown====+<code> 
 +root@debian11:~# systemctl enable apache2.service 
 +Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install. 
 +Executing: /lib/systemd/systemd-sysv-install enable apache2
  
-Lors de l'arrêt de la machine, Linux procède, entre autre, aux tâches suivantes :+Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service. 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service - The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) 
 +     Active: active (running) since Sat 2022-04-30 12:30:17 CEST; 1min 5s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +   Main PID: 56452 (apache2) 
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.7M 
 +        CPU: 39ms 
 +     CGroup: /system.slice/apache2.service 
 +             ├─56452 /usr/sbin/apache2 -k start 
 +             ├─56453 /usr/sbin/apache2 -k start 
 +             └─56454 /usr/sbin/apache2 -k start
  
-  * Il previent les utilisateurs,  +Apr 30 12:30:17 debian11 systemd[1]: Starting The Apache HTTP Server... 
-  * Il arrête tous les services, +Apr 30 12:30:17 debian11 systemd[1]: Started The Apache HTTP Server. 
-  * Il inscrit toutes les données sur disque, +</code>
-  * Il démonte les systèmes de fichiers.+
  
-La commande utilisée pour arrêter le système est la commande **shutdown** :+===6.2 - Gestion d'Instances Multiples===
  
-  shutdown [-t sec] [-akrhHPfnc] heure [message]+Systemd permet l'utilisation des gabarits (templates) des fichiers de configuration des Unités. De cette façon il est possible de faire coexister deux ou plusieurs instances du même service. Un gabarit est reconnaissable par le caractère **@** qui est placé juste avant le point dans le nom du fichier :
  
-===Options de la commande===+<code> 
 +root@debian11:~# cat /usr/lib/systemd/system/apache2@.service 
 +[Unit] 
 +Description=The Apache HTTP Server 
 +After=network.target remote-fs.target nss-lookup.target 
 +ConditionPathIsDirectory=/etc/apache2-%i 
 +Documentation=https://httpd.apache.org/docs/2.4/
  
-Les options de cette commande sont :+[Service] 
 +Type=forking 
 +Environment=APACHE_CONFDIR=/etc/apache2-%i APACHE_STARTED_BY_SYSTEMD=true 
 +ExecStart=/usr/sbin/apachectl start 
 +ExecStop=/usr/sbin/apachectl graceful-stop 
 +ExecReload=/usr/sbin/apachectl graceful 
 +KillMode=mixed 
 +PrivateTmp=true 
 +Restart=on-abort 
 + 
 +[Install] 
 +WantedBy=multi-user.target 
 +</code> 
 + 
 +Une instance créée à partir de ce gabarit devrait avoir un nom sous la forme suivante :
  
 <code> <code>
-Usage:    shutdown [-akrhHPfnc] [-t secs] time [warning message] +httpd@<nom_instance>.service
-                  -a:      use /etc/shutdown.allow +
-                  -k:      don't really shutdown, only warn. +
-                  -r:      reboot after shutdown. +
-                  -h:      halt after shutdown. +
-                  -P:      halt action is to turn off power. +
-                  -H:      halt action is to just halt. +
-                  -f:      do a 'fast' reboot (skip fsck). +
-                  -F:      Force fsck on reboot. +
-                  -n:      do not go through "init" but go down real fast. +
-                  -c:      cancel a running shutdown. +
-                  -t secs: delay between warning and kill signal. +
-                  ** the "time" argument is mandatory! (try "now") **+
 </code> </code>
  
-Parmi les options les plus importantes, on note :+Dans ce fichier on peut constater l'utilisation d'un **identifier** sous la forme de **%i**. Les identifiers sont de deux types - un dit **échappé** où les caractères non-ASCII alphanumérique sont remplacés par **escapes** de type langage C et l'autre non-échappé :
  
-^ Option ^ Description ^ +  * %n : est remplacé par le nom complet échappé de l'Unité. 
-| -h | Arrêter le système | +  * %N : est remplacé par le nom complet non-échappé de l'Unité. 
--r | Re-démarrer le système | +  * %p : est remplacé par le préfixe échappé de l'Unité, c'est-à-dire la partie **avant** le caractère @. 
--c | Annuler l'opération shutdown en cours | +  * %P : est remplacé par le préfixe non-échappé de l'Unité, c'est-à-dire la partie **avant** le caractère @. 
--f | Re-démarrer rapidement sans vérifier les systèmes de fichiers | +  * %i : est remplacé par le nom de l'instance échappé de l'Unité, c'est-à-dire la partie **après** le caractère @ et **avant** le point. 
-| -F | Forcer la vérification des systèmes de fichiers lors du prochain démarrage |+  * %I : est remplacé par le nom de l'instance non-échappé de l'Unité, c'est-à-dire la partie **après** le caractère @ et **avant** le point. 
 +  * %: est remplacé par le préfixe non-échappé ou le nom de l'instance non-échappé préfixé par le caractère **/**. 
 +  * %c : est remplacé par le CGroup de l'Unité sans le chemin /sys/fs/cgroup/systemd/
 +  * %u : est remplacé par le nom de l'utilisateur responsable de l'exécution de l'Unité. 
 +  * %U : est remplacé par l'UID de l'utilisateur responsable de l'exécution de l'Unité. 
 +  * %H : est remplacé par le nom d'hôte sur lequel est exécuté l'Unité. 
 +  * %% : est remplacé" par le caractère **%**.
  
-L'option **heure** peut prendre plusieurs valeurs :+Créez maintenant deux copies du fichier **/usr/lib/systemd/system/apache2@.service** :
  
-^ Valeur ^ Description ^ +<code> 
-| hh:mm | L'heure à laquelle l'opération aura lieu | +root@debian11:~# cp /usr/lib/systemd/system/apache2@.service /usr/lib/systemd/system/apache2@instance01.service 
-| +m | Nombre de minutes avant que l'opération aura lieu | +root@debian11:~# cp /usr/lib/systemd/system/apache2@.service /usr/lib/systemd/system/apache2@instance02.service 
-| now | L'opération est immédiate |+</code>
  
-<WRAP center round important> +Copiez le répertoire **/etc/apache2** vers **/etc/apache2-instance01** et **/etc/apache2-instance02** :
-**Important** : Si l'opération est programmée pour dans moins de 5 minutes, les connexions supplémentaires sont interdites, y comprises les tentatives de connexion de root. Notez aussi que l'utilisation de la commande **shutdown** peut être accordée à d'autres utilisateurs de root en utilisant le fichier **/etc/shutdown.allow**+
-</WRAP>+
  
-Dans votre VM, ouvrez deux terminaux. Dans le premier passez en tant que root. Planifiez ensuite un redémarrage de la VM dans 30 minutes :+<code> 
 +root@debian11:~# cp -r /etc/apache2/ /etc/apache2-instance01 
 +root@debian11:~# cp -r /etc/apache2/ /etc/apache2-instance02 
 +</code> 
 + 
 +Editez le fichier **vi /etc/apache2-instance01/ports.conf** en modifiant le port d'écoute à 81 :
  
 <code> <code>
-[root@centos7 ~]shutdown -r +30+root@debian11:~# vi /etc/apache2-instance01/ports.conf 
 +root@debian11:~# cat /etc/apache2-instance01/ports.conf 
 +# If you just change the port or add more ports here, you will likely also 
 +# have to change the VirtualHost statement in 
 +# /etc/apache2/sites-enabled/000-default.conf
  
-Broadcast message from trainee@centos.fenestros.loc +Listen 81
- (/dev/pts/0) at 10:12 ...+
  
-The system is going down for reboot in 30 minutes! +<IfModule ssl_module> 
-</code+        Listen 443 
 +</IfModule>
  
-Dans le deuxième terminal est passez en tant que routeAnnulez ensuite le shutdown :+<IfModule mod_gnutls.c> 
 +        Listen 443 
 +</IfModule>
  
-<code> +vim: syntax=apache ts=4 sw=4 sts=4 sr noet
-[trainee@centos7 ~]$ su - +
-Mot de passe :  +
-[root@centos7 ~]shutdown -c+
 </code> </code>
  
-Retournez au premier terminal et constatez le message affiché :+Editez le fichier **vi /etc/apache2-instance02/ports.conf** en modifiant le port d'écoute à 82 :
  
 <code> <code>
-[root@centos7 ~]shutdown -r +30+root@debian11:~# vi /etc/apache2-instance02/ports.conf 
 +root@debian11:~# cat /etc/apache2-instance02/ports.conf 
 +# If you just change the port or add more ports here, you will likely also 
 +# have to change the VirtualHost statement in 
 +# /etc/apache2/sites-enabled/000-default.conf
  
-Broadcast message from trainee@centos.fenestros.loc +Listen 82
- (/dev/pts/0) at 10:12 ...+
  
-The system is going down for reboot in 30 minutes!+<IfModule ssl_module> 
 +        Listen 443 
 +</IfModule>
  
 +<IfModule mod_gnutls.c>
 +        Listen 443
 +</IfModule>
  
-shutdown: Shutdown cancelled +vim: syntax=apache ts=4 sw=4 sts=4 sr noet
-[root@centos7 ~]#+
 </code> </code>
  
-==== La Commande reboot====+Editez la directive **APACHE_PID_FILE** du fichier **/etc/apache2-instance01/envvars** :
  
-Cette commande redémarre le système. Quand le système fonctionne normalement, l'exécution de reboot appelle la commande **shutdown -r**.+<code> 
 +root@debian11:~# vi /etc/apache2-instance01/envvars 
 +root@debian11:~# cat /etc/apache2-instance01/envvars 
 +# envvars - default environment variables for apache2ctl
  
-===Options de la commande===+# this won't be correct after changing uid 
 +unset HOME
  
-Les options de cette commande sont :+# for supporting multiple apache2 instances 
 +if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 
 +        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 
 +else 
 +        SUFFIX= 
 +fi 
 + 
 +# Since there is no sane way to get the parsed apache2 config in scripts, some 
 +# settings are defined via environment variables and then used in apache2ctl, 
 +# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc. 
 +export APACHE_RUN_USER=www-data 
 +export APACHE_RUN_GROUP=www-data 
 +# temporary state file location. This might be changed to /run in Wheezy+1 
 +export APACHE_PID_FILE=/var/run/apache2-instance01/apache2.pid 
 +export APACHE_RUN_DIR=/var/run/apache2$SUFFIX 
 +export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX 
 +# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2. 
 +export APACHE_LOG_DIR=/var/log/apache2$SUFFIX 
 + 
 +## The locale used by some modules like mod_dav 
 +export LANG=C 
 +## Uncomment the following line to use the system default locale instead: 
 +#. /etc/default/locale 
 + 
 +export LANG 
 + 
 +## The command to get the status for 'apache2ctl status'
 +## Some packages providing 'www-browser' need '--dump' instead of '-dump'
 +#export APACHE_LYNX='www-browser -dump' 
 + 
 +## If you need a higher file descriptor limit, uncomment and adjust the 
 +## following line (default is 8192): 
 +#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536' 
 + 
 +## If you would like to pass arguments to the web server, add them below 
 +## to the APACHE_ARGUMENTS environment. 
 +#export APACHE_ARGUMENTS='' 
 + 
 +## Enable the debug mode for maintainer scripts. 
 +## This will produce a verbose output on package installations of web server modules and web application 
 +## installations which interact with Apache 
 +#export APACHE2_MAINTSCRIPT_DEBUG=1 
 +</code>  
 + 
 +Editez la directive **APACHE_PID_FILE** du fichier **/etc/apache2-instance02/envvars** :
  
 <code> <code>
-[root@centos7 ~]reboot --help +root@debian11:~# vi /etc/apache2-instance02/envvars 
-Usagereboot [OPTION]... +root@debian11:~# cat /etc/apache2-instance02/envvars 
-Reboot the system.+# envvars - default environment variables for apache2ctl
  
-Options: +# this won'be correct after changing uid 
-  -n, --no-sync               don'sync before reboot or halt +unset HOME
-  -f, --force                 force reboot or halt, don't call shutdown(8) +
-  -p, --poweroff              switch off the power when called as halt +
-  -w, --wtmp-only             don't actually reboot or halt, just write wtmp +
-                                record +
-  -q, --quiet                 reduce output to errors only +
-  -v, --verbose               increase output to include informational messages +
-      --help                  display this help and exit +
-      --version               output version information and exit+
  
-This command is intended to instruct the kernel to reboot or halt the system; +# for supporting multiple apache2 instances 
-when run without the -f option, or when in a system runlevel other than 0 or 6, +if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then 
-it will actually execute /sbin/shutdown.+        SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" 
 +else 
 +        SUFFIX= 
 +fi
  
 +# Since there is no sane way to get the parsed apache2 config in scripts, some
 +# settings are defined via environment variables and then used in apache2ctl,
 +# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
 +export APACHE_RUN_USER=www-data
 +export APACHE_RUN_GROUP=www-data
 +# temporary state file location. This might be changed to /run in Wheezy+1
 +export APACHE_PID_FILE=/var/run/apache2-instance02/apache2.pid
 +export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
 +export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
 +# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
 +export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
  
-Report bugs to <upstart-devel@lists.ubuntu.com> +## The locale used by some modules like mod_dav 
-</code>+export LANG=C 
 +## Uncomment the following line to use the system default locale instead: 
 +#. /etc/default/locale
  
-==== La Commande halt====+export LANG
  
-Cette commande arrête le systèmeQuand le système fonctionne normalement, l'exécution de halt appelle la commande **shutdown -h**.+## The command to get the status for 'apache2ctl status'. 
 +## Some packages providing 'www-browser' need '--dump' instead of '-dump'. 
 +#export APACHE_LYNX='www-browser -dump'
  
-===Options de la commande===+## If you need a higher file descriptor limit, uncomment and adjust the 
 +## following line (default is 8192): 
 +#APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'
  
-Les options de cette commande sont :+## If you would like to pass arguments to the web server, add them below 
 +## to the APACHE_ARGUMENTS environment. 
 +#export APACHE_ARGUMENTS='' 
 + 
 +## Enable the debug mode for maintainer scripts. 
 +## This will produce a verbose output on package installations of web server modules and web application 
 +## installations which interact with Apache 
 +#export APACHE2_MAINTSCRIPT_DEBUG=1 
 +</code>  
 + 
 +Créez les répertoires **/var/log/apache2-instance01** et **/var/log/apache2-instance01** et modifiant le groupe associé :
  
 <code> <code>
-[root@centos7 ~]halt --help +root@debian11:~# mkdir /var/log/apache2-instance01 
-Usagehalt [OPTION]... +root@debian11:~# mkdir /var/log/apache2-instance02
-Halt the system.+
  
-Options+root@debian11:~# chown root:adm /var/log/apache2-instance01 
-  -n, --no-sync               don't sync before reboot or halt +root@debian11:~# chown root:adm /var/log/apache2-instance02 
-  -f, --force                 force reboot or haltdon't call shutdown(8+</code> 
-  -p, --poweroff              switch off the power when called as halt + 
-  -w, --wtmp-only             don't actually reboot or halt, just write wtmp +Démarrez les deux services : 
-                                record + 
-  -q, --quiet                 reduce output to errors only +<code> 
-  -v, --verbose               increase output to include informational messages +root@debian11:~# systemctl start apache2@instance01.service 
-      --help                  display this help and exit + 
-      --version               output version information and exit+root@debian11:~# systemctl status apache2@instance01.service 
 +● apache2@instance01.service The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2@instance01.service; disabled; vendor preset: enabled) 
 +     Active: active (running) since Sat 2022-04-30 13:51:47 CEST; 4s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +    Process: 56906 ExecStart=/usr/sbin/apachectl start (code=exitedstatus=0/SUCCESS) 
 +   Main PID: 56910 (apache2
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.8M 
 +        CPU: 31ms 
 +     CGroup: /system.slice/system-apache2.slice/apache2@instance01.service 
 +             ├─56910 /usr/sbin/apache2 -d /etc/apache2-instance01 -k start 
 +             ├─56911 /usr/sbin/apache2 -d /etc/apache2-instance01 -k start 
 +             └─56912 /usr/sbin/apache2 -d /etc/apache2-instance01 -k start 
 + 
 +Apr 30 13:51:47 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 13:51:47 debian11 systemd[1]: Started The Apache HTTP Server.
  
-This command is intended to instruct the kernel to reboot or halt the system; +root@debian11:~# systemctl start apache2@instance02.service
-when run without the -f option, or when in a system runlevel other than 0 or 6, +
-it will actually execute /sbin/shutdown.+
  
 +root@debian11:~# systemctl status apache2@instance02.service
 +● apache2@instance02.service - The Apache HTTP Server
 +     Loaded: loaded (/lib/systemd/system/apache2@instance02.service; disabled; vendor preset: enabled)
 +     Active: active (running) since Sat 2022-04-30 14:04:21 CEST; 10s ago
 +       Docs: https://httpd.apache.org/docs/2.4/
 +    Process: 57137 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 +   Main PID: 57148 (apache2)
 +      Tasks: 55 (limit: 4663)
 +     Memory: 8.8M
 +        CPU: 37ms
 +     CGroup: /system.slice/system-apache2.slice/apache2@instance02.service
 +             ├─57148 /usr/sbin/apache2 -d /etc/apache2-instance02 -k start
 +             ├─57149 /usr/sbin/apache2 -d /etc/apache2-instance02 -k start
 +             └─57150 /usr/sbin/apache2 -d /etc/apache2-instance02 -k start
  
-Report bugs to <upstart-devel@lists.ubuntu.com>+Apr 30 14:04:21 debian11 systemd[1]: Starting The Apache HTTP Server..
 +Apr 30 14:04:21 debian11 systemd[1]: Started The Apache HTTP Server.
 </code> </code>
  
-==== La Commande poweroff====+Installez l'exécutable **lynx** :
  
-Cette commande arrête le système et coupe l'alimentation électrique. Elle est l'équivalente de la commande **halt -p**. Quand le système fonctionne normalement, l'exécution de **poweroff** appelle la commande **shutdown -hP**.+<code> 
 +root@debian11:~# apt -y install lynx 
 +</code>
  
-===Options de la commande===+Testez ensuite les deux instances d'Apache :
  
-Les options de cette commande sont :+<code> 
 +root@debian11:~# lynx --dump http://localhost:81 | more 
 +   Debian Logo Apache2 Debian Default Page 
 +   It works! 
 + 
 +   This is the default welcome page used to test the correct operation of 
 +   the Apache2 server after installation on Debian systems. If you can 
 +   read this page, it means that the Apache HTTP server installed at this 
 +   site is working properly. You should replace this file (located at 
 +   /var/www/html/index.html) before continuing to operate your HTTP 
 +   server. 
 + 
 +   If you are a normal user of this web site and don't know what this page 
 +   is about, this probably means that the site is currently unavailable 
 +   due to maintenance. If the problem persists, please contact the site'
 +   administrator. 
 +   Configuration Overview 
 + 
 +   Debian's Apache2 default configuration is different from the upstream 
 +   default configuration, and split into several files optimized for 
 +   interaction with Debian tools. The configuration system is fully 
 +   documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this 
 +   for the full documentation. Documentation for the web server itself can 
 +   be found by accessing the [1]manual if the apache2-doc package was 
 +   installed on this server. 
 + 
 +   The configuration layout for an Apache2 web server installation on 
 +   Debian systems is as follows: 
 +/etc/apache2/ 
 +|-- apache2.conf 
 +|       `--  ports.conf 
 +|-- mods-enabled 
 +|       |-- *.load 
 +|       `-- *.conf 
 +|-- conf-enabled 
 +|       `-- *.conf 
 +|-- sites-enabled 
 +|       `-- *.conf 
 + 
 +     * apache2.conf is the main configuration file. It puts the pieces 
 +       together by including all remaining configuration files when 
 +       starting up the web server. 
 +     * ports.conf is always included from the main configuration file. It 
 +       is used to determine the listening ports for incoming connections, 
 +       and this file can be customized anytime. 
 +     * Configuration files in the mods-enabled/, conf-enabled/ and 
 +       sites-enabled/ directories contain particular configuration 
 +       snippets which manage modules, global configuration fragments, or 
 +       virtual host configurations, respectively. 
 +     * They are activated by symlinking available configuration files from 
 +       their respective *-available/ counterparts. These should be managed 
 +       by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and 
 +       a2enconf, a2disconf . See their respective man pages for detailed 
 +       information. 
 +     * The binary is called apache2. Due to the use of environment 
 +       variables, in the default configuration, apache2 needs to be 
 +       started/stopped with /etc/init.d/apache2 or apache2ctl. Calling 
 +       /usr/bin/apache2 directly will not work with the default 
 +       configuration. 
 + 
 +--More-- 
 +[q] 
 + 
 +root@debian11:~# lynx --dump http://localhost:82 | more 
 +   Debian Logo Apache2 Debian Default Page 
 +   It works! 
 + 
 +   This is the default welcome page used to test the correct operation of 
 +   the Apache2 server after installation on Debian systems. If you can 
 +   read this page, it means that the Apache HTTP server installed at this 
 +   site is working properly. You should replace this file (located at 
 +   /var/www/html/index.html) before continuing to operate your HTTP 
 +   server. 
 + 
 +   If you are a normal user of this web site and don't know what this page 
 +   is about, this probably means that the site is currently unavailable 
 +   due to maintenance. If the problem persists, please contact the site'
 +   administrator. 
 +   Configuration Overview 
 + 
 +   Debian's Apache2 default configuration is different from the upstream 
 +   default configuration, and split into several files optimized for 
 +   interaction with Debian tools. The configuration system is fully 
 +   documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this 
 +   for the full documentation. Documentation for the web server itself can 
 +   be found by accessing the [1]manual if the apache2-doc package was 
 +   installed on this server. 
 + 
 +   The configuration layout for an Apache2 web server installation on 
 +   Debian systems is as follows: 
 +/etc/apache2/ 
 +|-- apache2.conf 
 +|       `--  ports.conf 
 +|-- mods-enabled 
 +|       |-- *.load 
 +|       `-- *.conf 
 +|-- conf-enabled 
 +|       `-- *.conf 
 +|-- sites-enabled 
 +|       `-- *.conf 
 + 
 +     * apache2.conf is the main configuration file. It puts the pieces 
 +       together by including all remaining configuration files when 
 +       starting up the web server. 
 +     * ports.conf is always included from the main configuration file. It 
 +       is used to determine the listening ports for incoming connections, 
 +       and this file can be customized anytime. 
 +     * Configuration files in the mods-enabled/, conf-enabled/ and 
 +       sites-enabled/ directories contain particular configuration 
 +       snippets which manage modules, global configuration fragments, or 
 +       virtual host configurations, respectively. 
 +     * They are activated by symlinking available configuration files from 
 +       their respective *-available/ counterparts. These should be managed 
 +       by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and 
 +       a2enconf, a2disconf . See their respective man pages for detailed 
 +       information. 
 +     * The binary is called apache2. Due to the use of environment 
 +       variables, in the default configuration, apache2 needs to be 
 +       started/stopped with /etc/init.d/apache2 or apache2ctl. Calling 
 +       /usr/bin/apache2 directly will not work with the default 
 +       configuration. 
 + 
 +--More-- 
 +[q] 
 +</code> 
 + 
 +===6.3 - Interdire la Modification du Statut d'un Service=== 
 + 
 +Il est possible d'interdire la modification en utilisant la commande **systemctl mask**:
  
 <code> <code>
-[root@centos7 ~]poweroff --help +root@debian11:~# systemctl status apache2.service 
-Usagepoweroff [OPTION]... +● apache2.service The Apache HTTP Server 
-Power off the system.+     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) 
 +     Active: active (running) since Sat 2022-04-30 12:30:17 CEST; 1h 39min ago 
 +       Docshttps://httpd.apache.org/docs/2.4/ 
 +   Main PID: 56452 (apache2) 
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.7M 
 +        CPU: 379ms 
 +     CGroup: /system.slice/apache2.service 
 +             ├─56452 /usr/sbin/apache2 -k start 
 +             ├─56453 /usr/sbin/apache2 -k start 
 +             └─56454 /usr/sbin/apache2 -k start
  
-Options+Apr 30 12:30:17 debian11 systemd[1]: Starting The Apache HTTP Server... 
-  -n, --no-sync               don't sync before reboot or halt +Apr 30 12:30:17 debian11 systemd[1]: Started The Apache HTTP Server. 
-  -f, --force                 force reboot or haltdon't call shutdown(8+ 
-  -p, --poweroff              switch off the power when called as halt +root@debian11:~# systemctl mask apache2.service 
-  -w, --wtmp-only             don't actually reboot or haltjust write wtmp +Created symlink /etc/systemd/system/apache2.service → /dev/null. 
-                                record + 
-  -q, --quiet                 reduce output to errors only +root@debian11:~# systemctl list-unit-files --type=service | grep apache2 
-  -v, --verbose               increase output to include informational messages +apache2.service                            masked          enabled 
-      --help                  display this help and exit +apache2@.service                           disabled        enabled 
-      --version               output version information and exit+apache2@instance01.service                 disabled        enabled 
 +apache2@instance02.service                 disabled        enabled 
 + 
 +root@debian11:~# systemctl disable apache2.service 
 +Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install. 
 +Executing: /lib/systemd/systemd-sysv-install disable apache2 
 +Unit /etc/systemd/system/apache2.service is maskedignoring. 
 + 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service - The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled
 +     Active: active (running) since Sat 2022-04-30 14:17:14 CEST; 3s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +    Process: 57431 ExecStart=/usr/sbin/apachectl start (code=exitedstatus=0/SUCCESS) 
 +   Main PID: 57435 (apache2) 
 +      Tasks: 55 (limit: 4663) 
 +     Memory: 8.8M 
 +        CPU: 33ms 
 +     CGroup: /system.slice/apache2.service 
 +             ├─57435 /usr/sbin/apache2 -k start 
 +             ├─57436 /usr/sbin/apache2 -k start 
 +             └─57437 /usr/sbin/apache2 -k start 
 + 
 +Apr 30 14:17:14 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 14:17:14 debian11 systemd[1]: Started The Apache HTTP Server. 
 + 
 +root@debian11:~# systemctl stop apache2.service 
 + 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service 
 +     Loaded: masked (Reason: Unit apache2.service is masked.) 
 +     Active: inactive (dead) since Sat 2022-04-30 14:17:45 CEST; 3s ago 
 +   Main PID: 57435 (code=exitedstatus=0/SUCCESS) 
 +        CPU: 39ms 
 + 
 +Apr 30 14:17:14 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 14:17:14 debian11 systemd[1]: Started The Apache HTTP Server. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopping apache2.service... 
 +Apr 30 14:17:45 debian11 systemd[1]: apache2.service: Succeeded. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopped apache2.service. 
 + 
 +root@debian11:~# systemctl start apache2.service 
 +Failed to start apache2.service: Unit apache2.service is masked. 
 + 
 +root@debian11:~# systemctl unmask apache2.service 
 +Removed /etc/systemd/system/apache2.service. 
 + 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) 
 +     Active: inactive (dead) since Sat 2022-04-30 14:17:45 CEST; 1min 13s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +   Main PID: 57435 (code=exitedstatus=0/SUCCESS) 
 +        CPU: 39ms 
 + 
 +Apr 30 14:17:14 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 14:17:14 debian11 systemd[1]: Started The Apache HTTP Server. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopping apache2.service... 
 +Apr 30 14:17:45 debian11 systemd[1]: apache2.service: Succeeded. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopped apache2.service. 
 + 
 +root@debian11:~# systemctl enable apache2.service 
 +Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install. 
 +Executing: /lib/systemd/systemd-sysv-install enable apache2 
 + 
 +root@debian11:~# systemctl status apache2.service 
 +● apache2.service The Apache HTTP Server 
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) 
 +     Active: inactive (dead) since Sat 2022-04-30 14:17:45 CEST; 1min 20s ago 
 +       Docs: https://httpd.apache.org/docs/2.4/ 
 +   Main PID: 57435 (code=exited, status=0/SUCCESS) 
 +        CPU: 39ms 
 + 
 +Apr 30 14:17:14 debian11 systemd[1]: Starting The Apache HTTP Server... 
 +Apr 30 14:17:14 debian11 systemd[1]: Started The Apache HTTP Server. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopping apache2.service... 
 +Apr 30 14:17:45 debian11 systemd[1]: apache2.service: Succeeded. 
 +Apr 30 14:17:45 debian11 systemd[1]: Stopped apache2.service.
  
-This command is intended to instruct the kernel to reboot or halt the system; +root@debian11:~# systemctl start apache2.service
-when run without the -f option, or when in a system runlevel other than 0 or 6, +
-it will actually execute /sbin/shutdown.+
  
 +root@debian11:~# systemctl status apache2.service
 +● apache2.service - The Apache HTTP Server
 +     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
 +     Active: active (running) since Sat 2022-04-30 14:19:12 CEST; 3s ago
 +       Docs: https://httpd.apache.org/docs/2.4/
 +    Process: 57685 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 +   Main PID: 57689 (apache2)
 +      Tasks: 55 (limit: 4663)
 +     Memory: 8.7M
 +        CPU: 30ms
 +     CGroup: /system.slice/apache2.service
 +             ├─57689 /usr/sbin/apache2 -k start
 +             ├─57690 /usr/sbin/apache2 -k start
 +             └─57691 /usr/sbin/apache2 -k start
  
-Report bugs to <upstart-devel@lists.ubuntu.com>+Apr 30 14:19:11 debian11 systemd[1]: Starting The Apache HTTP Server..
 +Apr 30 14:19:12 debian11 systemd[1]: Started The Apache HTTP Server.
 </code> </code>
  
 ----- -----
-<html> 
-<div align="center"> 
 Copyright © 2022 Hugh Norris. Copyright © 2022 Hugh Norris.
-</html> 
Menu