Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
elearning:workbooks:centos:8:junior:l123 [2024/10/01 08:03] – removed admin | elearning:workbooks:centos:8:junior:l123 [2024/10/01 08:05] (Version actuelle) – created admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ~~PDF: | ||
+ | Version : **2024.01** | ||
+ | |||
+ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
+ | |||
+ | ======LCF603 - Gestion du Démarrage et de l' | ||
+ | |||
+ | =====Contenu du Module===== | ||
+ | |||
+ | * **LCF603 - Gestion du Démarrage et de l' | ||
+ | * Contenu du Module | ||
+ | * Présentation | ||
+ | * BIOS, EFI et OpenFirmware | ||
+ | * Systèmes à base du BIOS | ||
+ | * Charger de Démarrage | ||
+ | * Systèmes à base de l'EFI | ||
+ | * Autres Systèmes | ||
+ | * Gestionnaire d' | ||
+ | * GRUB 2 | ||
+ | * Le fichier / | ||
+ | * Le fichier / | ||
+ | * Les fichiers du répertoire /etc/grub.d | ||
+ | * Configurer l' | ||
+ | * Modifier la Configuration de GRUB 2 en Ligne de Commande | ||
+ | * Chargeurs de Démarrages Alternatifs | ||
+ | * Systemd-boot | ||
+ | * U-boot | ||
+ | * Le Projet Syslinux | ||
+ | * SYSLINUX | ||
+ | * EXTLINUX | ||
+ | * ISOLINUX | ||
+ | * PXELINUX | ||
+ | * Isodhpfx | ||
+ | * Initramfs | ||
+ | * Examiner l' | ||
+ | * Le script init | ||
+ | * Consulter le contenu d'un fichier dans initramfs | ||
+ | * Processus de Démarrage du Noyau Linux | ||
+ | * Processus Init | ||
+ | * Systemd | ||
+ | * LAB #1 - La Commande systemctl | ||
+ | * LAB #2 - Fichiers de Configuration | ||
+ | * 2.1 - Fichiers de Configuration par Défaut | ||
+ | * 2.2 - Surchargement des Fichiers de Configuration par Défaut | ||
+ | * LAB #3 - La Commande systemd-analyze | ||
+ | * LAB #4 - Les Cibles Systemd | ||
+ | * 4.1 - Contrôler les dépendances d'une Cible | ||
+ | * 4.2 - La Cible par Défaut | ||
+ | * LAB #5 - Gestion des Services | ||
+ | * 5.1 - Gestion des Instances Uniques | ||
+ | * 5.2 - Gestion d' | ||
+ | * 5.3 - Interdire la Modification du Statut d'un Service | ||
+ | * Arrêt Système du Système | ||
+ | * La Commande shutdown | ||
+ | * La Commande reboot | ||
+ | * La Commande halt | ||
+ | * La Commande poweroff | ||
+ | |||
+ | =====Présentation===== | ||
+ | |||
+ | Le processus de démarrage de Linux peut être résumé en trois étapes majeurs : | ||
+ | |||
+ | * Le **firmware** ou **micrologiciel** démarre en effectuant un test rapide du matériel, appelé un **Power-On Self Test** ou **POST**, puis recherche le **Charger de Démarrage** (// | ||
+ | * Le Charger de Démarrage est exécuté et il détermine quel noyau Linux à charger, | ||
+ | * Le noyau se charge en mémoire et commence à exécuter en arrière plan les programmes nécessaires au fonctionnement du système. | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | **A retenir** : Il est possible de consulter le défilement des messages lors du démarrage en appuyant sur la touche < | ||
+ | </ | ||
+ | |||
+ | Cette description simpliste résume cependant un processus bien plus compliqué que ce cours va détailler. | ||
+ | |||
+ | =====BIOS, EFI et OpenFirmware===== | ||
+ | |||
+ | ====Systèmes à base du BIOS==== | ||
+ | |||
+ | Au démarrage d'un système à base d'un processeur x86 ou x86-64, le premier programme exécuté a été traditionnellement le BIOS. Le BIOS a pour fonction de : | ||
+ | |||
+ | * Tester les composants et les circuits, | ||
+ | * Faire appel au BIOS de la carte graphique pour initialiser le système d' | ||
+ | * Détecter les périphériques de stockage, | ||
+ | * Lancer le **Charger de Démarrage** du système d' | ||
+ | |||
+ | ===Chargeur de Démarrage=== | ||
+ | |||
+ | La première partie du Chargeur de Démarrage est en règle générale placé dans le MBR du disque. Le format du MBR est le suivant : | ||
+ | |||
+ | * 446 octets pour le Charger de Démarrage, | ||
+ | * 64 octets pour la table de partitions, soit 16 octets par partition décrite, | ||
+ | * 2 octets ayant une valeur fixe en hexadécimale de **AA55**. | ||
+ | |||
+ | ====Systèmes à base de l' | ||
+ | |||
+ | Depuis 2011, le BIOS est en train d' | ||
+ | |||
+ | Sous EFI la première partie du gestionnaire de démarrage est un fichier ayant une extension .efi se trouvant dans un sous-répertoire au nom du système d' | ||
+ | |||
+ | Pour que EFI fonctionne, le micrologiciel (**firmware**) d'EFI doit avoir connaissance de chaque système d' | ||
+ | |||
+ | <WRAP center round tip 60%> | ||
+ | **A retenir** : Sous Linux c'est l' | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : L'UEFI gère les **SSD** (//Solid State Drives//) qui utilisent le standard **NVMe** (// | ||
+ | </ | ||
+ | |||
+ | ====Autres Systèmes==== | ||
+ | |||
+ | Les systèmes utilisant des processeurs autre qu'un x86 ou x86-64 utilisent un logiciel tel **[[http:// | ||
+ | |||
+ | =====Gestionnaires de Démarrage===== | ||
+ | |||
+ | ====GRUB 2==== | ||
+ | |||
+ | GRUB 2 est une ré-écriture complète de GRUB Legacy. Il apporte des améliorations, | ||
+ | |||
+ | Le lancement de GRUB 2 se fait en trois étapes : | ||
+ | |||
+ | * Etape 1 : Le **boot.img**, | ||
+ | * Etape 1.5 : Le **core.img**, | ||
+ | * Etape 2 : Contenu dans le répertoire **/ | ||
+ | |||
+ | Dans le cas où le Charger de Démarrage **GRUB 2** n'est pas installé, il convient de saisir la commande suivante : | ||
+ | |||
+ | # grub2-install / | ||
+ | |||
+ | où **périphérique** est le nom du périphérique ou l' | ||
+ | |||
+ | **GRUB 2** lit ses entrées de menus à partir du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | # | ||
+ | # DO NOT EDIT THIS FILE | ||
+ | # | ||
+ | # It is automatically generated by grub2-mkconfig using templates | ||
+ | # from /etc/grub.d and settings from / | ||
+ | # | ||
+ | |||
+ | ### BEGIN / | ||
+ | set pager=1 | ||
+ | |||
+ | if [ -f ${config_directory}/ | ||
+ | load_env -f ${config_directory}/ | ||
+ | elif [ -s $prefix/ | ||
+ | load_env | ||
+ | fi | ||
+ | if [ " | ||
+ | set default=" | ||
+ | set next_entry= | ||
+ | | ||
+ | set boot_once=true | ||
+ | else | ||
+ | set default=" | ||
+ | fi | ||
+ | |||
+ | if [ x" | ||
+ | menuentry_id_option=" | ||
+ | else | ||
+ | menuentry_id_option="" | ||
+ | fi | ||
+ | |||
+ | export menuentry_id_option | ||
+ | |||
+ | if [ " | ||
+ | set saved_entry=" | ||
+ | save_env saved_entry | ||
+ | set prev_saved_entry= | ||
+ | save_env prev_saved_entry | ||
+ | set boot_once=true | ||
+ | fi | ||
+ | |||
+ | function savedefault { | ||
+ | if [ -z " | ||
+ | saved_entry=" | ||
+ | save_env saved_entry | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | function load_video { | ||
+ | if [ x$feature_all_video_module = xy ]; then | ||
+ | insmod all_video | ||
+ | else | ||
+ | insmod efi_gop | ||
+ | insmod efi_uga | ||
+ | insmod ieee1275_fb | ||
+ | insmod vbe | ||
+ | insmod vga | ||
+ | insmod video_bochs | ||
+ | insmod video_cirrus | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | terminal_output console | ||
+ | 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 | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | set tuned_params="" | ||
+ | set tuned_initrd="" | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ " | ||
+ | set last_boot_ok=1 | ||
+ | else | ||
+ | set last_boot_ok=0 | ||
+ | fi | ||
+ | |||
+ | # Reset boot_indeterminate after a successful boot | ||
+ | if [ " | ||
+ | set boot_indeterminate=0 | ||
+ | # Avoid boot_indeterminate causing the menu to be hidden more then once | ||
+ | elif [ " | ||
+ | set boot_indeterminate=2 | ||
+ | fi | ||
+ | set boot_success=0 | ||
+ | save_env boot_success boot_indeterminate | ||
+ | |||
+ | if [ x$feature_timeout_style = xy ] ; then | ||
+ | if [ " | ||
+ | unset menu_show_once | ||
+ | save_env menu_show_once | ||
+ | set timeout_style=menu | ||
+ | set timeout=60 | ||
+ | elif [ " | ||
+ | set orig_timeout_style=${timeout_style} | ||
+ | set orig_timeout=${timeout} | ||
+ | if [ " | ||
+ | # timeout_style=menu + timeout=0 avoids the countdown code keypress check | ||
+ | set timeout_style=menu | ||
+ | set timeout=0 | ||
+ | else | ||
+ | set timeout_style=hidden | ||
+ | set timeout=1 | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ -f ${prefix}/ | ||
+ | source ${prefix}/ | ||
+ | if [ -n " | ||
+ | set superusers=" | ||
+ | export superusers | ||
+ | password_pbkdf2 root ${GRUB2_PASSWORD} | ||
+ | fi | ||
+ | fi | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | set root=' | ||
+ | if [ x$feature_platform_search_hint = xy ]; then | ||
+ | search --no-floppy --fs-uuid --set=root --hint-bios=hd0, | ||
+ | else | ||
+ | search --no-floppy --fs-uuid --set=root 2ae4c035-9244-458c-82c5-a49ae169cdb6 | ||
+ | fi | ||
+ | insmod part_msdos | ||
+ | insmod ext2 | ||
+ | set boot=' | ||
+ | if [ x$feature_platform_search_hint = xy ]; then | ||
+ | search --no-floppy --fs-uuid --set=boot --hint-bios=hd0, | ||
+ | else | ||
+ | search --no-floppy --fs-uuid --set=boot 2ae4c035-9244-458c-82c5-a49ae169cdb6 | ||
+ | fi | ||
+ | |||
+ | # This section was generated by a script. Do not modify the generated file - all changes | ||
+ | # will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files. | ||
+ | # | ||
+ | # The blscfg command parses the BootLoaderSpec files stored in / | ||
+ | # populates the boot menu. Please refer to the Boot Loader Specification documentation | ||
+ | # for the files format: https:// | ||
+ | |||
+ | set default_kernelopts=" | ||
+ | |||
+ | insmod blscfg | ||
+ | blscfg | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | # This file provides an easy way to add custom menu entries. | ||
+ | # menu entries you want to add after this comment. | ||
+ | # the 'exec tail' line above. | ||
+ | ### END / | ||
+ | |||
+ | ### BEGIN / | ||
+ | if [ -f ${config_directory}/ | ||
+ | source ${config_directory}/ | ||
+ | elif [ -z " | ||
+ | source $prefix/ | ||
+ | fi | ||
+ | ### END / | ||
+ | </ | ||
+ | |||
+ | Notez que ce fichier ne doit pas être modifié manuellement. En effet, il est généré par la commande **grub2-mkconfig**. La commande grub2-mkconfig prend en argument l' | ||
+ | |||
+ | * grub2-mkconfig -o / | ||
+ | * grub2-mkconfig -o / | ||
+ | |||
+ | Lors de l' | ||
+ | |||
+ | ===Le fichier / | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | # this device map was generated by anaconda | ||
+ | (hd0) /dev/sda | ||
+ | (hd1) /dev/sda | ||
+ | </ | ||
+ | |||
+ | ===Le fichier / | ||
+ | |||
+ | Ce fichier contient la configuration par défaut des paramètres de GRUB 2 : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | GRUB_TIMEOUT=5 | ||
+ | GRUB_DISTRIBUTOR=" | ||
+ | GRUB_DEFAULT=saved | ||
+ | GRUB_DISABLE_SUBMENU=true | ||
+ | GRUB_TERMINAL_OUTPUT=" | ||
+ | GRUB_CMDLINE_LINUX=" | ||
+ | GRUB_DISABLE_RECOVERY=" | ||
+ | GRUB_ENABLE_BLSCFG=true | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Notez que toute modification de ce fichier nécessite l' | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier les directives sont : | ||
+ | |||
+ | ^ Directive | ||
+ | | GRUB_TIMEOUT | Durée de l' | ||
+ | | GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l' | ||
+ | | GRUB_DEFAULT | Entrée du menu sélectionner par défaut | | ||
+ | | GRUB_DISABLE_SUBMENU | Active ou désactive les sous-menus de GRUB2 | | ||
+ | | GRUB_TERMINAL_OUTPUT | Spécifie le terminal par défaut | | ||
+ | | GRUB_CMDLINE_LINUX | Paramètres passés au noyau peu importe le type de démarrage | | ||
+ | | GRUB_DISABLE_RECOVERY | Active ou désactive la génération des entrées en mode **recovery** | | ||
+ | | GRUB_BLSCFG | Active ou désactive l' | ||
+ | |||
+ | ===Les fichiers du répertoire / | ||
+ | |||
+ | Les fichiers de ce répertoire sont exécutés dans l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l /etc/grub.d | ||
+ | total 92 | ||
+ | -rwxr-xr-x. 1 root root 8958 Mar 2 15:51 00_header | ||
+ | -rwxr-xr-x. 1 root root 1043 Jun 15 2020 00_tuned | ||
+ | -rwxr-xr-x. 1 root root 232 Mar 2 15:51 01_users | ||
+ | -rwxr-xr-x. 1 root root 832 Mar 2 15:51 08_fallback_counting | ||
+ | -rwxr-xr-x. 1 root root 14088 Mar 2 15:51 10_linux | ||
+ | -rwxr-xr-x. 1 root root 830 Mar 2 15:51 10_reset_boot_success | ||
+ | -rwxr-xr-x. 1 root root 889 Mar 2 15:51 12_menu_auto_hide | ||
+ | -rwxr-xr-x. 1 root root 11696 Mar 2 15:51 20_linux_xen | ||
+ | -rwxr-xr-x. 1 root root 2559 Mar 2 15:51 20_ppc_terminfo | ||
+ | -rwxr-xr-x. 1 root root 10670 Mar 2 15:51 30_os-prober | ||
+ | -rwxr-xr-x. 1 root root 1412 Mar 2 15:51 30_uefi-firmware | ||
+ | -rwxr-xr-x. 1 root root 214 Mar 2 15:51 40_custom | ||
+ | -rwxr-xr-x. 1 root root 216 Mar 2 15:51 41_custom | ||
+ | -rw-r--r--. 1 root root 483 Mar 2 15:51 README | ||
+ | </ | ||
+ | |||
+ | * **Le fichier / | ||
+ | * Le fichier **10_Linux** contient des boucles pour rechercher des noyaux Linux, | ||
+ | * **Le fichier / | ||
+ | * Ce fichier recherche des éventuels systèmes d' | ||
+ | * **Les fichiers / | ||
+ | * Ces deux fichiers sont fournis en tant que modèles à personnaliser. | ||
+ | |||
+ | ===Le Fichier / | ||
+ | |||
+ | Le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | # GRUB Environment Block | ||
+ | saved_entry=de79af4f226d480fa7d3fec4cabbf97a-4.18.0-240.22.1.el8_3.x86_64 | ||
+ | kernelopts=root=UUID=4c0cc28c-0d59-45be-bd73-d292b80be33c ro crashkernel=auto resume=UUID=c8bb3f47-d67f-4b21-b781-766899dc83d4 rhgb quiet | ||
+ | boot_success=1 | ||
+ | boot_indeterminate=0 | ||
+ | ########################################################################################################################################## | ||
+ | ########################################################################################################################################## | ||
+ | ########################################################################################################################################## | ||
+ | ########################################################################################################################################## | ||
+ | ########################################################################################################################################## | ||
+ | ############################################################ | ||
+ | </ | ||
+ | |||
+ | ===Modifier la Configuration de GRUB 2 en Ligne de Commande=== | ||
+ | |||
+ | Lors du démarrage de GRUB 2, trois actions sont possibles à partir du menu : | ||
+ | |||
+ | * Lancer un système d' | ||
+ | * Lancer l' | ||
+ | * Lancer l’interface de la ligne de commande GRUB en appuyant sur la touche **c**. | ||
+ | |||
+ | En mode édition notez l' | ||
+ | |||
+ | * **flèches** : se déplacer dans l' | ||
+ | * **Crtl-X** : démarrer avec la configuration modifiée, | ||
+ | * **echap** : abandonner les modifications et retourner à l' | ||
+ | |||
+ | ====Chargeurs de Démarrages Alternatifs==== | ||
+ | |||
+ | ===Systemd-boot=== | ||
+ | |||
+ | Un Chargeur de Démarrage étroitement lié à Systemd ( voir plus bas ), celui-ci connaît actuellement un gain de popularité. | ||
+ | |||
+ | ===U-boot=== | ||
+ | |||
+ | Un Chargeur de Démarrage qui peut booter n' | ||
+ | |||
+ | ===Le Projet Syslinux=== | ||
+ | |||
+ | ==SYSLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour les systèmes qui utilisent le système de fichier FAT. Par exemple le systèmes sur clefs USB. | ||
+ | |||
+ | ==EXTLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage de petite taille qui sait booter des systèmes de fichier, EXT2, EXT3, EXT4 et BRTFS. | ||
+ | |||
+ | ==ISOLINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour booter des LiveCD et LiveDVD. Dans le cas d' | ||
+ | |||
+ | * **isolinux.bin** qui contient l' | ||
+ | * **isolinux.cfg** qui contient les paramètres de configuration. | ||
+ | |||
+ | ==PXELINUX== | ||
+ | |||
+ | Un Chargeur de Démarrage pour booter à partir d'un serveur réseau. Ce système utilise le standard **PXE** (//Pre-boot Execution Environment// | ||
+ | |||
+ | * **DHCP** pour attribuer une adresse IP à la machine et | ||
+ | * **BOOTP** pour charger l' | ||
+ | |||
+ | ===Isodhpfx=== | ||
+ | |||
+ | Un Chargeur de Démarrage hybride, appelé **isodhpfx.bin**, | ||
+ | |||
+ | ====Initramfs==== | ||
+ | |||
+ | Le fichier Initramfs //%%INITial Ram File System%%// est une archive au format cpio : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cp / | ||
+ | [root@centos8 ~]# cd /tmp | ||
+ | [root@centos8 tmp]# ls | ||
+ | cpio.list | ||
+ | custom | ||
+ | dateref | ||
+ | incremental.tar | ||
+ | mbr.save | ||
+ | systemd-private-9af7a2f7444849578f55b306bfd9f820-chronyd.service-iQiNzF | ||
+ | tblpart.save | ||
+ | test.cpio | ||
+ | test.print | ||
+ | test.tar | ||
+ | tmp.iso | ||
+ | vg0_backup | ||
+ | |||
+ | [root@centos8 tmp]# mv custom custom.gz | ||
+ | |||
+ | [root@centos8 tmp]# gunzip custom.gz | ||
+ | |||
+ | [root@centos8 tmp]# mkdir initramfs | ||
+ | |||
+ | [root@centos8 tmp]# cd initramfs | ||
+ | |||
+ | [root@centos8 initramfs]# cpio -cid -I ../custom | ||
+ | 216 blocks | ||
+ | [root@centos8 initramfs]# ls | ||
+ | bin dev etc init lib lib64 proc root run sbin shutdown | ||
+ | </ | ||
+ | |||
+ | ===Examiner l' | ||
+ | |||
+ | Pour examiner une image initramfs archivée, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 tmp]# lsinitrd custom | more | ||
+ | Image: custom: 25M | ||
+ | ======================================================================== | ||
+ | Early CPIO image | ||
+ | ======================================================================== | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | ======================================================================== | ||
+ | Version: dracut-049-95.git20200804.el8_3.4 | ||
+ | |||
+ | Arguments: -f --kver ' | ||
+ | |||
+ | dracut modules: | ||
+ | bash | ||
+ | systemd | ||
+ | systemd-initrd | ||
+ | nss-softokn | ||
+ | rngd | ||
+ | i18n | ||
+ | network-legacy | ||
+ | network | ||
+ | ifcfg | ||
+ | drm | ||
+ | plymouth | ||
+ | prefixdevname | ||
+ | kernel-modules | ||
+ | kernel-modules-extra | ||
+ | kernel-network-modules | ||
+ | resume | ||
+ | rootfs-block | ||
+ | terminfo | ||
+ | udev-rules | ||
+ | biosdevname | ||
+ | dracut-systemd | ||
+ | usrmount | ||
+ | base | ||
+ | fs-lib | ||
+ | memstrack | ||
+ | microcode_ctl-fw_dir_override | ||
+ | shutdown | ||
+ | ======================================================================== | ||
+ | drwxr-xr-x | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | crw-r--r-- | ||
+ | lrwxrwxrwx | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x | ||
+ | -rw-r--r-- | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | ===Le script init=== | ||
+ | |||
+ | RHEL/CentOS 8 utilise le système de démarrage **systemd**. Pour cette raison le script init est un lien symbolique vers **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 tmp]# lsinitrd custom | grep usr/ | ||
+ | lrwxrwxrwx | ||
+ | </ | ||
+ | |||
+ | ===Consulter le contenu d'un fichier dans initramfs=== | ||
+ | |||
+ | Pour consulter le contenu d'un fichier inclus dans l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 tmp]# lsinitrd / | ||
+ | include ld.so.conf.d/ | ||
+ | </ | ||
+ | |||
+ | ====Processus de Démarrage du Noyau Linux==== | ||
+ | |||
+ | Le processus de démarrage du Noyau Linux peut être divisé en 6 étapes : | ||
+ | |||
+ | ^ Etape ^ Description ^ | ||
+ | | Chargement, configuration et exécution du chargeur du noyau | Le fichier **bootsect.s** est chargé en mémoire par le BIOS. Une fois configuré celui-ci charge le reste du noyau en mémoire | | ||
+ | | Configuration des paramètres et bascule vers le mode 32 bits | Le fichier **boot.s** met en place un **[[http:// | ||
+ | | Décompression du Noyau | Le fichier **head.s** décompresse le noyau | | ||
+ | | Initialisation du noyau et de la mémoire | Le fichier **head.s** crée un GDT et IDT définitif | | ||
+ | | Configuration du noyau | Le fichier **main.c** met en place les contraintes de mémoire et configure la mémoire virtuelle | | ||
+ | | Création du processus Init | Le fichier **main.c** crée le processus init | | ||
+ | |||
+ | La fonction **init_post()** essaie ensuite d' | ||
+ | |||
+ | * /sbin/init ==> / | ||
+ | * /etc/init | ||
+ | * /bin/init | ||
+ | * /bin/sh ==> /bin/bash ==> / | ||
+ | |||
+ | Dans le cas d'un échec à ce stade le message **Kernel Panic** sera affiché. | ||
+ | |||
+ | =====Systemd===== | ||
+ | |||
+ | Les systèmes de démarrage antérieurs à Systemd, **SysVinit** et **Upstart**, | ||
+ | |||
+ | **Systemd** essaie, par contre, de démarrer autant de services en parallèle que possible. Ceci est rendu possible car la majorité d' | ||
+ | |||
+ | Au lieu de parler de scripts de démarrage et de niveaux d' | ||
+ | |||
+ | * **.automount** - active la fonctionalité d' | ||
+ | * **.device** - expose une périphérique dans systemd. | ||
+ | * **.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' | ||
+ | * **.swap** - encapsule une périphérique ou un fichier swap. | ||
+ | * **.timer** - déclenche l' | ||
+ | * **.target** - regroupe des Unités multiples afin qu' | ||
+ | |||
+ | 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' | ||
+ | * **hibernate.target** - sauvegarde l' | ||
+ | * **reboot.target** - redémarre le système. | ||
+ | |||
+ | **Systemd** utilise des Cibles d'une manière similaire à ce que **SysVinit** utilise des niveaux d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 15 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 13 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 17 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 17 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 17 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 13 Apr 7 16:55 / | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | |||
+ | / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | ====LAB #1 - La Commande systemctl==== | ||
+ | |||
+ | Pour visualiser la liste des Unités, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-units | ||
+ | UNIT LOAD | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-pci0000: | ||
+ | sys-devices-platform-serial8250-tty-ttyS0.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS1.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS2.device | ||
+ | sys-devices-platform-serial8250-tty-ttyS3.device | ||
+ | sys-devices-virtual-block-dm\x2d0.device | ||
+ | sys-devices-virtual-block-dm\x2d1.device | ||
+ | sys-devices-virtual-net-virbr0.device | ||
+ | sys-devices-virtual-net-virbr0\x2dnic.device | ||
+ | sys-module-configfs.device | ||
+ | sys-subsystem-net-devices-enp0s3.device | ||
+ | sys-subsystem-net-devices-virbr0.device | ||
+ | sys-subsystem-net-devices-virbr0\x2dnic.device | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | run-user-1000.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | sys-kernel-tracing.mount | ||
+ | var-lib-nfs-rpc_pipefs.mount | ||
+ | cups.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | init.scope | ||
+ | session-96.scope | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | avahi-daemon.service | ||
+ | chronyd.service | ||
+ | crond.service | ||
+ | cups.service | ||
+ | dbus.service | ||
+ | dracut-shutdown.service | ||
+ | firewalld.service | ||
+ | lines 1-57 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités inactifs, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-units --all | grep inactive | more | ||
+ | ● boot.automount | ||
+ | proc-fs-nfsd.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | ● sysroot.mount | ||
+ | tmp.mount | ||
+ | var-lib-machines.mount | ||
+ | systemd-ask-password-console.path | ||
+ | ● apparmor.service | ||
+ | auth-rpcgss-module.service | ||
+ | cpupower.service | ||
+ | ● display-manager.service | ||
+ | dm-event.service | ||
+ | dnf-makecache.service | ||
+ | dracut-cmdline.service | ||
+ | dracut-initqueue.service | ||
+ | dracut-mount.service | ||
+ | dracut-pre-mount.service | ||
+ | dracut-pre-pivot.service | ||
+ | dracut-pre-trigger.service | ||
+ | dracut-pre-udev.service | ||
+ | ebtables.service | ||
+ | emergency.service | ||
+ | initrd-cleanup.service | ||
+ | initrd-parse-etc.service | ||
+ | initrd-switch-root.service | ||
+ | initrd-udevadm-cleanup-db.service | ||
+ | ● ip6tables.service | ||
+ | ● ipset.service | ||
+ | ● iptables.service | ||
+ | iscsi-onboot.service | ||
+ | iscsi.service | ||
+ | iscsid.service | ||
+ | iscsiuio.service | ||
+ | ldconfig.service | ||
+ | libvirt-guests.service | ||
+ | libvirtd.service | ||
+ | loadmodules.service | ||
+ | ● lvm2-activation.service | ||
+ | lvm2-lvmpolld.service | ||
+ | mdmonitor.service | ||
+ | microcode.service | ||
+ | ● network.service | ||
+ | nfs-blkmap.service | ||
+ | nfs-convert.service | ||
+ | nfs-idmapd.service | ||
+ | nfs-mountd.service | ||
+ | nfs-server.service | ||
+ | nfs-utils.service | ||
+ | nfsdcld.service | ||
+ | nftables.service | ||
+ | ● ntpd.service | ||
+ | ● ntpdate.service | ||
+ | plymouth-switch-root.service | ||
+ | rc-local.service | ||
+ | rescue.service | ||
+ | rpc-gssd.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de certaines lignes dans la sortie ci-dessus sont en réalité des points blancs à l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl status ntpd | ||
+ | Unit ntpd.service could not be found. | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des Unités ainsi que leurs statuts, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-unit-files | more | ||
+ | UNIT FILE STATE | ||
+ | proc-sys-fs-binfmt_misc.automount | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-fs-nfsd.mount | ||
+ | proc-sys-fs-binfmt_misc.mount | ||
+ | sys-fs-fuse-connections.mount | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | tmp.mount | ||
+ | var-lib-machines.mount | ||
+ | var-lib-nfs-rpc_pipefs.mount | ||
+ | cups.path | ||
+ | systemd-ask-password-console.path | ||
+ | systemd-ask-password-plymouth.path | ||
+ | systemd-ask-password-wall.path | ||
+ | session-96.scope | ||
+ | arp-ethers.service | ||
+ | atd.service | ||
+ | auditd.service | ||
+ | auth-rpcgss-module.service | ||
+ | autovt@.service | ||
+ | avahi-daemon.service | ||
+ | blk-availability.service | ||
+ | chrony-dnssrv@.service | ||
+ | chrony-wait.service | ||
+ | chronyd.service | ||
+ | cockpit-motd.service | ||
+ | cockpit-wsinstance-http-redirect.service | ||
+ | cockpit-wsinstance-http.service | ||
+ | cockpit-wsinstance-https-factory@.service | ||
+ | cockpit-wsinstance-https@.service | ||
+ | cockpit.service | ||
+ | console-getty.service | ||
+ | container-getty@.service | ||
+ | cpupower.service | ||
+ | crond.service | ||
+ | cups-browsed.service | ||
+ | cups.service | ||
+ | dbus-org.fedoraproject.FirewallD1.service | ||
+ | dbus-org.freedesktop.Avahi.service | ||
+ | dbus-org.freedesktop.hostname1.service | ||
+ | dbus-org.freedesktop.import1.service | ||
+ | dbus-org.freedesktop.locale1.service | ||
+ | dbus-org.freedesktop.login1.service | ||
+ | dbus-org.freedesktop.machine1.service | ||
+ | dbus-org.freedesktop.nm-dispatcher.service | ||
+ | dbus-org.freedesktop.portable1.service | ||
+ | dbus-org.freedesktop.timedate1.service | ||
+ | dbus.service | ||
+ | debug-shell.service | ||
+ | dm-event.service | ||
+ | dnf-makecache.service | ||
+ | dnsmasq.service | ||
+ | dracut-cmdline.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Pour visualiser les Unités d'un type spécifique, | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-unit-files -t mount | ||
+ | UNIT FILE | ||
+ | -.mount | ||
+ | boot.mount | ||
+ | dev-hugepages.mount | ||
+ | dev-mqueue.mount | ||
+ | proc-fs-nfsd.mount | ||
+ | proc-sys-fs-binfmt_misc.mount static | ||
+ | sys-fs-fuse-connections.mount static | ||
+ | sys-kernel-config.mount | ||
+ | sys-kernel-debug.mount | ||
+ | tmp.mount | ||
+ | var-lib-machines.mount | ||
+ | var-lib-nfs-rpc_pipefs.mount | ||
+ | |||
+ | 12 unit files listed. | ||
+ | </ | ||
+ | |||
+ | Dans la colonne STATE on voit les mots **static** et **generated**. | ||
+ | |||
+ | * STATE = static | ||
+ | * Ceci implique que l' | ||
+ | |||
+ | * STATE = generated | ||
+ | * Ceci implique que le fichier a été généré automatiquement en utilisant les informations dans le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | -rwxr-xr-x. 1 root root 46096 Apr 7 16:56 / | ||
+ | </ | ||
+ | |||
+ | Il existe aussi d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 508 | ||
+ | -rwxr-xr-x. 1 root root 504 Jan 4 11:25 kdump-dep-generator.sh | ||
+ | -r-xr-xr-x. 1 root root 134976 Aug 17 2020 lvm2-activation-generator | ||
+ | -rwxr-xr-x. 1 root root 67792 Jul 20 2020 nfs-server-generator | ||
+ | -rwxr-xr-x. 1 root root 38216 Jul 20 2020 rpc-pipefs-generator | ||
+ | -rwxr-xr-x. 1 root root 743 Apr 23 2020 selinux-autorelabel-generator.sh | ||
+ | -rwxr-xr-x. 1 root root 33504 Apr 7 16:56 systemd-cryptsetup-generator | ||
+ | -rwxr-xr-x. 1 root root 16648 Apr 7 16:56 systemd-debug-generator | ||
+ | -rwxr-xr-x. 1 root root 46096 Apr 7 16:56 systemd-fstab-generator | ||
+ | -rwxr-xr-x. 1 root root 17064 Apr 7 16:56 systemd-getty-generator | ||
+ | -rwxr-xr-x. 1 root root 29432 Apr 7 16:56 systemd-gpt-auto-generator | ||
+ | -rwxr-xr-x. 1 root root 12568 Apr 7 16:56 systemd-hibernate-resume-generator | ||
+ | -rwxr-xr-x. 1 root root 12368 Apr 7 16:56 systemd-rc-local-generator | ||
+ | -rwxr-xr-x. 1 root root 12408 Apr 7 16:56 systemd-system-update-generator | ||
+ | -rwxr-xr-x. 1 root root 33544 Apr 7 16:56 systemd-sysv-generator | ||
+ | -rwxr-xr-x. 1 root root 17024 Apr 7 16:56 systemd-veritysetup-generator | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemctl** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl --help | ||
+ | systemctl [OPTIONS...] {COMMAND} ... | ||
+ | |||
+ | Query or send control commands to the systemd manager. | ||
+ | |||
+ | -h --help | ||
+ | | ||
+ | | ||
+ | | ||
+ | -H --host=[USER@]HOST | ||
+ | Operate on remote host | ||
+ | -M --machine=CONTAINER | ||
+ | Operate on local container | ||
+ | -t --type=TYPE | ||
+ | | ||
+ | -p --property=NAME | ||
+ | -a --all Show all properties/ | ||
+ | including dead/empty ones. To list all units installed on | ||
+ | the system, use the ' | ||
+ | | ||
+ | -l --full | ||
+ | -r --recursive | ||
+ | | ||
+ | | ||
+ | queueing a new job | ||
+ | | ||
+ | | ||
+ | -i --ignore-inhibitors | ||
+ | When shutting down or sleeping, ignore inhibitors | ||
+ | | ||
+ | -s --signal=SIGNAL | ||
+ | | ||
+ | | ||
+ | -q --quiet | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | Do not ask for system passwords | ||
+ | | ||
+ | | ||
+ | reboot | ||
+ | -f --force | ||
+ | When shutting down, execute action immediately | ||
+ | | ||
+ | | ||
+ | directory | ||
+ | -n --lines=INTEGER | ||
+ | -o --output=STRING | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | lines 1-57 | ||
+ | </ | ||
+ | |||
+ | ====LAB #2 - Fichiers de Configuration==== | ||
+ | |||
+ | ===2.1 - Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration des Cibles et fichiers de configuration des Unités installés par des paquets se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# pkg-config systemd --variable=systemdsystemunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 1464 | ||
+ | -rw-r--r--. 1 root root 275 Apr 26 2020 arp-ethers.service | ||
+ | -rw-r--r--. 1 root root 222 May 11 2019 atd.service | ||
+ | -rw-r--r--. 1 root root 1512 Apr 23 2020 auditd.service | ||
+ | -rw-r--r--. 1 root root 628 Jul 20 2020 auth-rpcgss-module.service | ||
+ | lrwxrwxrwx. 1 root root 14 Apr 7 16:55 autovt@.service -> getty@.service | ||
+ | -rw-r--r--. 1 root root 1044 Nov 16 2020 avahi-daemon.service | ||
+ | -rw-r--r--. 1 root root 870 Nov 16 2020 avahi-daemon.socket | ||
+ | -rw-r--r--. 1 root root 956 Apr 7 16:54 basic.target | ||
+ | drwxr-xr-x. 2 root root 6 Apr 7 16:55 basic.target.wants | ||
+ | -r--r--r--. 1 root root 408 Aug 17 2020 blk-availability.service | ||
+ | -rw-r--r--. 1 root root 419 Jun 22 2018 bluetooth.target | ||
+ | -rw-r--r--. 1 root root 455 Apr 7 16:54 boot-complete.target | ||
+ | -rw-r--r--. 1 root root 209 Nov 19 2019 chrony-dnssrv@.service | ||
+ | -rw-r--r--. 1 root root 138 Nov 19 2019 chrony-dnssrv@.timer | ||
+ | -rw-r--r--. 1 root root 491 Nov 19 2019 chronyd.service | ||
+ | -rw-r--r--. 1 root root 472 May 10 2019 chrony-wait.service | ||
+ | -rw-r--r--. 1 root root 222 Aug 24 2020 cockpit-motd.service | ||
+ | -rw-r--r--. 1 root root 835 Aug 24 2020 cockpit.service | ||
+ | -rw-r--r--. 1 root root 373 Aug 24 2020 cockpit.socket | ||
+ | -rw-r--r--. 1 root root 251 Aug 24 2020 cockpit-wsinstance-http-redirect.service | ||
+ | -rw-r--r--. 1 root root 233 Aug 24 2020 cockpit-wsinstance-http-redirect.socket | ||
+ | -rw-r--r--. 1 root root 221 Aug 24 2020 cockpit-wsinstance-http.service | ||
+ | -rw-r--r--. 1 root root 165 Aug 24 2020 cockpit-wsinstance-https-factory@.service | ||
+ | -rw-r--r--. 1 root root 244 Aug 24 2020 cockpit-wsinstance-https-factory.socket | ||
+ | -rw-r--r--. 1 root root 215 Aug 24 2020 cockpit-wsinstance-http.socket | ||
+ | -rw-r--r--. 1 root root 264 Aug 24 2020 cockpit-wsinstance-https@.service | ||
+ | -rw-r--r--. 1 root root 478 Aug 24 2020 cockpit-wsinstance-https@.socket | ||
+ | -rw-r--r--. 1 root root 1082 Apr 7 16:55 console-getty.service | ||
+ | -rw-r--r--. 1 root root 1263 Apr 7 16:55 container-getty@.service | ||
+ | -rw-r--r--. 1 root root 294 Apr 8 15:21 cpupower.service | ||
+ | -rw-r--r--. 1 root root 356 Nov 8 2019 crond.service | ||
+ | -rw-r--r--. 1 root root 465 Jun 22 2018 cryptsetup-pre.target | ||
+ | -rw-r--r--. 1 root root 412 Jun 22 2018 cryptsetup.target | ||
+ | lrwxrwxrwx. 1 root root 13 Apr 7 16:55 ctrl-alt-del.target -> reboot.target | ||
+ | -rw-r--r--. 1 root root 234 Oct 4 2017 cups-browsed.service | ||
+ | -r--r--r--. 1 root root 142 Jun 15 2020 cups.path | ||
+ | -r--r--r--. 1 root root 248 Jun 15 2020 cups.service | ||
+ | -r--r--r--. 1 root root 136 Jun 15 2020 cups.socket | ||
+ | lrwxrwxrwx. 1 root root 25 Apr 7 16:55 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service | ||
+ | lrwxrwxrwx. 1 root root 23 Apr 7 16:55 dbus-org.freedesktop.import1.service -> systemd-importd.service | ||
+ | lrwxrwxrwx. 1 root root 23 Apr 7 16:55 dbus-org.freedesktop.locale1.service -> systemd-localed.service | ||
+ | lrwxrwxrwx. 1 root root 22 Apr 7 16:55 dbus-org.freedesktop.login1.service -> systemd-logind.service | ||
+ | lrwxrwxrwx. 1 root root 24 Apr 7 16:55 dbus-org.freedesktop.machine1.service -> systemd-machined.service | ||
+ | lrwxrwxrwx. 1 root root 25 Apr 7 16:55 dbus-org.freedesktop.portable1.service -> systemd-portabled.service | ||
+ | lrwxrwxrwx. 1 root root 25 Apr 7 16:55 dbus-org.freedesktop.timedate1.service -> systemd-timedated.service | ||
+ | -rw-r--r--. 1 root root 380 Apr 7 12:08 dbus.service | ||
+ | -rw-r--r--. 1 root root 102 Apr 7 12:08 dbus.socket | ||
+ | drwxr-xr-x. 2 root root 6 Apr 7 16:55 dbus.target.wants | ||
+ | -rw-r--r--. 1 root root 1084 Apr 7 16:55 debug-shell.service | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 default.target -> graphical.target | ||
+ | drwxr-xr-x. 2 root root 6 Apr 7 16:55 default.target.wants | ||
+ | -rw-r--r--. 1 root root 750 Jun 22 2018 dev-hugepages.mount | ||
+ | -rw-r--r--. 1 root root 665 Jun 22 2018 dev-mqueue.mount | ||
+ | -r--r--r--. 1 root root 345 Aug 17 2020 dm-event.service | ||
+ | -r--r--r--. 1 root root 248 Aug 17 2020 dm-event.socket | ||
+ | -rw-r--r--. 1 root root 457 Jun 2 2020 dnf-makecache.service | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Certains fichiers de configuration sont créés à la volée dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | Les fichiers de configuration des Unités crées par les utilisateurs doivent être mis dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# pkg-config systemd --variable=systemduserunitdir | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : De cette façon les fichiers dans **/ | ||
+ | </ | ||
+ | |||
+ | Prenons le cas du service **sshd** qui est configuré par le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | [Unit] | ||
+ | Description=OpenSSH server daemon | ||
+ | Documentation=man: | ||
+ | After=network.target sshd-keygen.target | ||
+ | Wants=sshd-keygen.target | ||
+ | |||
+ | [Service] | ||
+ | Type=notify | ||
+ | EnvironmentFile=-/ | ||
+ | EnvironmentFile=-/ | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | KillMode=process | ||
+ | Restart=on-failure | ||
+ | RestartSec=42s | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Dans le fichier on peut noter la présence des lignes suivantes dans la section **[Unit]** : | ||
+ | |||
+ | * **Description=OpenSSH server daemon**, | ||
+ | * Cette directive est utilisée pour donner une courte description des fonctionnalités de l' | ||
+ | * **Documentation=man: | ||
+ | * Cette directive stipule les chapitres des manuels et les URLs contenant de l' | ||
+ | * **After=network.target sshd-keygen.target**, | ||
+ | * Cette directive indique les cibles qui devraient être atteintes et les Unités qui devraient être démarrées avant l' | ||
+ | * **Wants=sshd-keygen.target**, | ||
+ | * Cette directive stipule une dépendance douce. Autrement dit, Systemd essayera de démarrer l' | ||
+ | |||
+ | 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=/ | ||
+ | * Cette directive définit l' | ||
+ | * **ExecReload=/ | ||
+ | * 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' | ||
+ | * **Restart=on-failure**, | ||
+ | * Cette ligne indique que le service doit être re-démarré en cas d' | ||
+ | * **RestartSec=42s**, | ||
+ | * Cette directive stipule le temps d' | ||
+ | |||
+ | Dernièrement on note la présence de la ligne suivante dans la section **[Install]** : | ||
+ | |||
+ | * **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 **/ | ||
+ | |||
+ | Pour consulter **l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl show sshd | ||
+ | Type=notify | ||
+ | Restart=on-failure | ||
+ | NotifyAccess=main | ||
+ | RestartUSec=42s | ||
+ | TimeoutStartUSec=1min 30s | ||
+ | TimeoutStopUSec=1min 30s | ||
+ | RuntimeMaxUSec=infinity | ||
+ | WatchdogUSec=0 | ||
+ | WatchdogTimestamp=Thu 2021-06-03 15:09:54 EDT | ||
+ | WatchdogTimestampMonotonic=12502561 | ||
+ | PermissionsStartOnly=no | ||
+ | RootDirectoryStartOnly=no | ||
+ | RemainAfterExit=no | ||
+ | GuessMainPID=yes | ||
+ | MainPID=902 | ||
+ | ControlPID=0 | ||
+ | FileDescriptorStoreMax=0 | ||
+ | NFileDescriptorStore=0 | ||
+ | StatusErrno=0 | ||
+ | Result=success | ||
+ | UID=[not set] | ||
+ | GID=[not set] | ||
+ | NRestarts=0 | ||
+ | ExecMainStartTimestamp=Thu 2021-06-03 15:09:54 EDT | ||
+ | ExecMainStartTimestampMonotonic=12446178 | ||
+ | ExecMainExitTimestampMonotonic=0 | ||
+ | ExecMainPID=902 | ||
+ | ExecMainCode=0 | ||
+ | ExecMainStatus=0 | ||
+ | ExecStart={ path=/ | ||
+ | ExecReload={ path=/ | ||
+ | Slice=system.slice | ||
+ | ControlGroup=/ | ||
+ | MemoryCurrent=6270976 | ||
+ | CPUUsageNSec=[not set] | ||
+ | EffectiveCPUs= | ||
+ | EffectiveMemoryNodes= | ||
+ | TasksCurrent=1 | ||
+ | IPIngressBytes=18446744073709551615 | ||
+ | IPIngressPackets=18446744073709551615 | ||
+ | IPEgressBytes=18446744073709551615 | ||
+ | IPEgressPackets=18446744073709551615 | ||
+ | Delegate=no | ||
+ | CPUAccounting=no | ||
+ | CPUWeight=[not set] | ||
+ | StartupCPUWeight=[not set] | ||
+ | CPUShares=[not set] | ||
+ | StartupCPUShares=[not set] | ||
+ | CPUQuotaPerSecUSec=infinity | ||
+ | CPUQuotaPeriodUSec=infinity | ||
+ | AllowedCPUs= | ||
+ | AllowedMemoryNodes= | ||
+ | IOAccounting=no | ||
+ | IOWeight=[not set] | ||
+ | StartupIOWeight=[not set] | ||
+ | BlockIOAccounting=no | ||
+ | BlockIOWeight=[not set] | ||
+ | lines 1-57 | ||
+ | </ | ||
+ | |||
+ | Pour consulter la liste des dépendances d'une Unité, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-dependencies sshd.service | ||
+ | sshd.service | ||
+ | ● ├─system.slice | ||
+ | ● ├─sshd-keygen.target | ||
+ | ● │ ├─sshd-keygen@ecdsa.service | ||
+ | ● │ ├─sshd-keygen@ed25519.service | ||
+ | ● │ └─sshd-keygen@rsa.service | ||
+ | ● └─sysinit.target | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● | ||
+ | ● │ ├─-.mount | ||
+ | ● │ ├─boot.mount | ||
+ | ● │ └─systemd-remount-fs.service | ||
+ | ● | ||
+ | ● | ||
+ | </ | ||
+ | |||
+ | ===2.2 - Surchargement des Fichiers de Configuration par Défaut=== | ||
+ | |||
+ | Les fichiers de configuration par défaut peuvent aussi être surchargés par des fichiers dans d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# pkg-config systemd --variable=systemdsystemunitpath | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 4 | ||
+ | drwxr-xr-x. 2 root root 31 May 8 2020 basic.target.wants | ||
+ | lrwxrwxrwx. 1 root root 41 May 8 2020 dbus-org.fedoraproject.FirewallD1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Jun 3 14:02 dbus-org.freedesktop.Avahi.service -> / | ||
+ | lrwxrwxrwx. 1 root root 57 May 8 2020 dbus-org.freedesktop.nm-dispatcher.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 May 8 2020 dbus-org.freedesktop.timedate1.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 May 8 2020 default.target -> / | ||
+ | drwxr-xr-x. 2 root root 32 May 8 2020 getty.target.wants | ||
+ | drwxr-xr-x. 2 root root 4096 Jun 3 14:02 multi-user.target.wants | ||
+ | drwxr-xr-x. 2 root root 48 May 8 2020 network-online.target.wants | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 nfs-blkmap.service.requires | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 nfs-idmapd.service.requires | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 nfs-mountd.service.requires | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 nfs-server.service.requires | ||
+ | drwxr-xr-x. 2 root root 26 Jun 3 14:02 printer.target.wants | ||
+ | drwxr-xr-x. 2 root root 52 Apr 19 12:07 remote-fs.target.wants | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 rpc-gssd.service.requires | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 rpc-statd-notify.service.requires | ||
+ | drwxr-xr-x. 2 root root 33 Apr 19 12:07 rpc-statd.service.requires | ||
+ | drwxr-xr-x. 2 root root 260 Jun 3 14:02 sockets.target.wants | ||
+ | drwxr-xr-x. 2 root root 235 Apr 19 12:07 sysinit.target.wants | ||
+ | lrwxrwxrwx. 1 root root 39 May 8 2020 syslog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 9 May 11 2019 systemd-timedated.service -> /dev/null | ||
+ | drwxr-xr-x. 2 root root 34 May 8 2020 timers.target.wants | ||
+ | </ | ||
+ | |||
+ | ====LAB #3 - La Commande systemd-analyze==== | ||
+ | |||
+ | Pour avoir une évaluation du temps de démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemd-analyze | ||
+ | Startup finished in 1.665s (kernel) + 6.977s (initrd) + 8.458s (userspace) = 17.101s | ||
+ | multi-user.target reached after 5.528s in userspace | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemd-analyze blame | ||
+ | 4.080s dracut-initqueue.service | ||
+ | 3.257s kdump.service | ||
+ | 1.727s tuned.service | ||
+ | 1.415s initrd-switch-root.service | ||
+ | 1.393s NetworkManager-wait-online.service | ||
+ | 1.116s systemd-machined.service | ||
+ | 1.111s dracut-cmdline.service | ||
+ | 850ms sssd.service | ||
+ | 791ms vdo.service | ||
+ | 713ms firewalld.service | ||
+ | 622ms lvm2-monitor.service | ||
+ | 605ms polkit.service | ||
+ | 508ms chronyd.service | ||
+ | 434ms avahi-daemon.service | ||
+ | 426ms systemd-logind.service | ||
+ | 417ms netcf-transaction.service | ||
+ | 410ms dracut-pre-udev.service | ||
+ | 295ms libvirtd.service | ||
+ | 275ms dnf-makecache.service | ||
+ | 243ms systemd-udevd.service | ||
+ | 221ms systemd-journald.service | ||
+ | 196ms systemd-tmpfiles-setup.service | ||
+ | 151ms dracut-pre-pivot.service | ||
+ | 139ms sysroot.mount | ||
+ | 139ms systemd-update-utmp-runlevel.service | ||
+ | 122ms systemd-vconsole-setup.service | ||
+ | 110ms lvm2-pvscan@8: | ||
+ | 98ms systemd-udev-trigger.service | ||
+ | 82ms gssproxy.service | ||
+ | 81ms cups.service | ||
+ | 79ms initrd-parse-etc.service | ||
+ | 77ms NetworkManager.service | ||
+ | 72ms lvm2-pvscan@8: | ||
+ | 69ms systemd-user-sessions.service | ||
+ | 68ms lvm2-pvscan@8: | ||
+ | 67ms unbound-anchor.service | ||
+ | 66ms rsyslog.service | ||
+ | 62ms boot.mount | ||
+ | 56ms sshd.service | ||
+ | 54ms smartd.service | ||
+ | 54ms systemd-fsck@dev-disk-by\x2duuid-2ae4c035\x2d9244\x2d458c\x2d82c5\x2da49ae169cdb6.service | ||
+ | 53ms user@1000.service | ||
+ | 52ms auditd.service | ||
+ | 51ms plymouth-quit.service | ||
+ | 49ms rngd-wake-threshold.service | ||
+ | 46ms import-state.service | ||
+ | 46ms systemd-tmpfiles-setup-dev.service | ||
+ | 43ms ksmtuned.service | ||
+ | 42ms plymouth-quit-wait.service | ||
+ | 42ms var-lib-nfs-rpc_pipefs.mount | ||
+ | 42ms rpc-statd-notify.service | ||
+ | 38ms plymouth-switch-root.service | ||
+ | 37ms systemd-remount-fs.service | ||
+ | 37ms plymouth-start.service | ||
+ | 33ms dev-disk-by\x2duuid-c8bb3f47\x2dd67f\x2d4b21\x2db781\x2d766899dc83d4.swap | ||
+ | 33ms systemd-tmpfiles-clean.service | ||
+ | 31ms dev-hugepages.mount | ||
+ | lines 1-57 | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemd-analyze critical-chain sshd.service | ||
+ | The time after the unit is active or started is printed after the " | ||
+ | The time the unit takes to start is printed after the " | ||
+ | |||
+ | sshd.service +56ms | ||
+ | └─network.target @3.799s | ||
+ | └─NetworkManager.service @3.719s +77ms | ||
+ | └─network-pre.target @3.718s | ||
+ | └─firewalld.service @3.004s +713ms | ||
+ | └─polkit.service @2.397s +605ms | ||
+ | └─basic.target @2.392s | ||
+ | └─sockets.target @2.392s | ||
+ | └─sssd-kcm.socket @2.391s | ||
+ | └─sysinit.target @2.379s | ||
+ | └─systemd-update-utmp.service @2.370s +8ms | ||
+ | └─auditd.service @2.317s +52ms | ||
+ | └─systemd-tmpfiles-setup.service @2.118s +196ms | ||
+ | └─import-state.service @2.070s +46ms | ||
+ | └─local-fs.target @2.069s | ||
+ | └─boot.mount @2.006s +62ms | ||
+ | └─systemd-fsck@dev-disk-by\x2duuid-2ae4c035\x2d9244\x2d458c\x2d82c5\x2da49ae169cdb6.service @1.943s +54ms | ||
+ | └─local-fs-pre.target @1.942s | ||
+ | └─lvm2-monitor.service @1.319s +622ms | ||
+ | └─dm-event.socket @1.317s | ||
+ | └─-.mount | ||
+ | └─system.slice | ||
+ | └─-.slice | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **systemd-analyze** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# systemd-analyze --help | ||
+ | systemd-analyze [OPTIONS...] {COMMAND} ... | ||
+ | |||
+ | Process systemd profiling information | ||
+ | |||
+ | -h --help | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | When generating a dependency graph, filter only origins | ||
+ | or destinations, | ||
+ | | ||
+ | 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 | ||
+ | | ||
+ | |||
+ | Commands: | ||
+ | time Print time spent in the kernel before reaching userspace | ||
+ | blame Print list of running units ordered by time to init | ||
+ | critical-chain | ||
+ | plot Output SVG graphic showing service initialization | ||
+ | dot | ||
+ | set-log-level LEVEL Set logging threshold for systemd | ||
+ | dump Output state serialization of service manager | ||
+ | </ | ||
+ | |||
+ | ====LAB #4 - Les Cibles Systemd==== | ||
+ | |||
+ | Chaque Cible est décrite par un fichier de configuration : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | # SPDX-License-Identifier: | ||
+ | # | ||
+ | # This file is part of systemd. | ||
+ | # | ||
+ | # systemd is free software; you can redistribute it and/or modify it | ||
+ | # under the terms of the GNU Lesser General Public License as published by | ||
+ | # the Free Software Foundation; either version 2.1 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | |||
+ | [Unit] | ||
+ | Description=Graphical Interface | ||
+ | Documentation=man: | ||
+ | Requires=multi-user.target | ||
+ | Wants=display-manager.service | ||
+ | Conflicts=rescue.service rescue.target | ||
+ | After=multi-user.target rescue.service rescue.target display-manager.service | ||
+ | AllowIsolate=yes | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier on peut noter la présence des lignes suivantes : | ||
+ | |||
+ | * **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 au préalable, | ||
+ | * **After=multi-user.target rescue.service rescue.target display-manager.service**, | ||
+ | * Cette ligne indique le **multi-user.target** et **rescue.target** doivent d' | ||
+ | * **Conflicts=rescue.service rescue.target**, | ||
+ | * Cette ligne indique la Cible et le service en conflits avec le **graphical.target**, | ||
+ | * **Wants=display-manager.service**, | ||
+ | * Cette ligne indique quel service doit être démarré. | ||
+ | |||
+ | ===4.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** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl list-dependencies multi-user.target | ||
+ | multi-user.target | ||
+ | ● ├─atd.service | ||
+ | ● ├─auditd.service | ||
+ | ● ├─avahi-daemon.service | ||
+ | ● ├─chronyd.service | ||
+ | ● ├─crond.service | ||
+ | ● ├─cups.path | ||
+ | ● ├─cups.service | ||
+ | ● ├─dbus.service | ||
+ | ● ├─dnf-makecache.timer | ||
+ | ● ├─firewalld.service | ||
+ | ● ├─irqbalance.service | ||
+ | ● ├─kdump.service | ||
+ | ● ├─ksm.service | ||
+ | ● ├─ksmtuned.service | ||
+ | ● ├─libstoragemgmt.service | ||
+ | ● ├─libvirtd.service | ||
+ | ● ├─mcelog.service | ||
+ | ● ├─mdmonitor.service | ||
+ | ● ├─netcf-transaction.service | ||
+ | ● ├─NetworkManager.service | ||
+ | ● ├─plymouth-quit-wait.service | ||
+ | ● ├─plymouth-quit.service | ||
+ | ● ├─rpcbind.service | ||
+ | ● ├─rsyslog.service | ||
+ | ● ├─smartd.service | ||
+ | ● ├─sshd.service | ||
+ | ● ├─sssd.service | ||
+ | ● ├─systemd-ask-password-wall.path | ||
+ | ● ├─systemd-logind.service | ||
+ | ● ├─systemd-update-utmp-runlevel.service | ||
+ | ● ├─systemd-user-sessions.service | ||
+ | ● ├─tuned.service | ||
+ | ● ├─vdo.service | ||
+ | ● ├─basic.target | ||
+ | ● │ ├─-.mount | ||
+ | ● │ ├─microcode.service | ||
+ | ● │ ├─paths.target | ||
+ | ● │ ├─slices.target | ||
+ | ● │ │ ├─-.slice | ||
+ | ● │ │ └─system.slice | ||
+ | ● │ ├─sockets.target | ||
+ | ● │ │ ├─avahi-daemon.socket | ||
+ | ● │ │ ├─cups.socket | ||
+ | ● │ │ ├─dbus.socket | ||
+ | ● │ │ ├─dm-event.socket | ||
+ | ● │ │ ├─iscsid.socket | ||
+ | ● │ │ ├─iscsiuio.socket | ||
+ | ● │ │ ├─libvirtd-ro.socket | ||
+ | ● │ │ ├─libvirtd.socket | ||
+ | ● │ │ ├─rpcbind.socket | ||
+ | ● │ │ ├─sssd-kcm.socket | ||
+ | ● │ │ ├─systemd-coredump.socket | ||
+ | ● │ │ ├─systemd-initctl.socket | ||
+ | ● │ │ ├─systemd-journald-dev-log.socket | ||
+ | ● │ │ ├─systemd-journald.socket | ||
+ | ● │ │ ├─systemd-udevd-control.socket | ||
+ | lines 1-57 | ||
+ | </ | ||
+ | |||
+ | Les points noirs au début de chaque ligne dans la sortie ci-dessus peuvent être de trois couleurs différentes : | ||
+ | |||
+ | * **Vert** implique que le service, la cible ou l' | ||
+ | * **Blanc** implique le service, la cible ou l' | ||
+ | * **Rouge** implique que le service, la cible ou l' | ||
+ | |||
+ | Pour visualiser les Unités en état d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl --failed | ||
+ | 0 loaded units listed. Pass --all to see loaded but inactive units, too. | ||
+ | To show all installed unit files use ' | ||
+ | </ | ||
+ | |||
+ | Les dépendances sont créés sous la forme de liens symboliques dans les répertoires **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 35 May 8 2020 atd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 May 8 2020 auditd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 44 Jun 3 14:02 avahi-daemon.service -> / | ||
+ | lrwxrwxrwx. 1 root root 39 May 8 2020 chronyd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 May 8 2020 crond.service -> / | ||
+ | lrwxrwxrwx. 1 root root 33 Jun 3 14:02 cups.path -> / | ||
+ | lrwxrwxrwx. 1 root root 36 Jun 3 14:02 cups.service -> / | ||
+ | lrwxrwxrwx. 1 root root 43 May 8 2020 dnf-makecache.timer -> / | ||
+ | lrwxrwxrwx. 1 root root 41 May 8 2020 firewalld.service -> / | ||
+ | lrwxrwxrwx. 1 root root 42 May 8 2020 irqbalance.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 May 8 2020 kdump.service -> / | ||
+ | lrwxrwxrwx. 1 root root 35 Apr 19 12:07 ksm.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Apr 19 12:07 ksmtuned.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 May 8 2020 libstoragemgmt.service -> / | ||
+ | lrwxrwxrwx. 1 root root 40 Apr 19 12:07 libvirtd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 May 8 2020 mcelog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 May 8 2020 mdmonitor.service -> / | ||
+ | lrwxrwxrwx. 1 root root 49 Apr 19 12:07 netcf-transaction.service -> / | ||
+ | lrwxrwxrwx. 1 root root 46 May 8 2020 NetworkManager.service -> / | ||
+ | lrwxrwxrwx. 1 root root 41 Apr 19 12:07 nfs-client.target -> / | ||
+ | lrwxrwxrwx. 1 root root 40 May 8 2020 remote-fs.target -> / | ||
+ | lrwxrwxrwx. 1 root root 39 Apr 19 12:07 rpcbind.service -> / | ||
+ | lrwxrwxrwx. 1 root root 39 May 8 2020 rsyslog.service -> / | ||
+ | lrwxrwxrwx. 1 root root 38 May 8 2020 smartd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 May 8 2020 sshd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 36 May 8 2020 sssd.service -> / | ||
+ | lrwxrwxrwx. 1 root root 37 May 8 2020 tuned.service -> / | ||
+ | lrwxrwxrwx. 1 root root 35 May 8 2020 vdo.service -> / | ||
+ | |||
+ | [root@centos8 ~]# ls -l / | ||
+ | total 0 | ||
+ | lrwxrwxrwx. 1 root root 15 Apr 7 12:08 dbus.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 15 Apr 7 16:55 getty.target -> ../ | ||
+ | lrwxrwxrwx. 1 root root 24 Oct 6 2020 plymouth-quit.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 29 Oct 6 2020 plymouth-quit-wait.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 33 Apr 7 16:55 systemd-ask-password-wall.path -> ../ | ||
+ | lrwxrwxrwx. 1 root root 25 Apr 7 16:55 systemd-logind.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 39 Apr 7 16:55 systemd-update-utmp-runlevel.service -> ../ | ||
+ | lrwxrwxrwx. 1 root root 32 Apr 7 16:55 systemd-user-sessions.service -> ../ | ||
+ | </ | ||
+ | |||
+ | ===4.2 - La Cible par Défaut=== | ||
+ | |||
+ | ==Consulter la Cible par Défaut== | ||
+ | |||
+ | Pour consulter la cible par défaut, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl get-default | ||
+ | multi-user.target | ||
+ | </ | ||
+ | |||
+ | La Cible par défaut est représentée par le lien symbolique **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 37 May 8 2020 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible par Défaut== | ||
+ | |||
+ | Pour modifier la Cible par défaut avec une prise en compte lors du **prochain** démarrage, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl set-default graphical.target | ||
+ | Removed / | ||
+ | Created symlink / | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 40 Jun 6 08:11 / | ||
+ | [root@centos8 ~]# systemctl set-default multi-user.target | ||
+ | Removed / | ||
+ | Created symlink / | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 41 Jun 6 08:11 / | ||
+ | </ | ||
+ | |||
+ | ==Modifier la Cible en Cours== | ||
+ | |||
+ | Il est possible de modifier la cible actuellement en cours en utilisant la commande **systemctl isolate** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl isolate rescue | ||
+ | [root@centos8 ~]# systemctl list-units --type target | egrep " | ||
+ | rescue.target | ||
+ | [root@centos8 ~]# runlevel | ||
+ | 3 1 | ||
+ | [root@centos8 ~]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl isolate multi-user | ||
+ | [root@centos8 ~]# systemctl list-units --type target | egrep " | ||
+ | multi-user.target | ||
+ | [root@centos8 ~]# runlevel | ||
+ | 1 3 | ||
+ | [root@centos8 ~]# who -r | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====LAB #5 - Gestion des Services==== | ||
+ | |||
+ | ===5.1 - Gestion des Instances Uniques=== | ||
+ | |||
+ | Commencez par installer le paquet **httpd** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# dnf install httpd | ||
+ | </ | ||
+ | |||
+ | Pour obtenir le détail sur un service donné, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | </ | ||
+ | |||
+ | Dans le cas du service httpd ci-dessus, on peut constater que le statut est **disabled**. 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** : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl is-enabled httpd.service | ||
+ | disabled | ||
+ | </ | ||
+ | |||
+ | Pour rendre le statut **enabled**, | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl enable httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@centos8 ~]# systemctl is-enabled httpd.service | ||
+ | enabled | ||
+ | |||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | </ | ||
+ | |||
+ | Dans le cas du service httpd ci-dessus, on peut maintenant constater que l' | ||
+ | |||
+ | * **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' | ||
+ | * **deactivating** - le service est en cours de désactivation. | ||
+ | * **failed** - le service a rencontré une erreur fatale. | ||
+ | |||
+ | Il est possible de vérifier l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl is-active httpd.service | ||
+ | inactive | ||
+ | </ | ||
+ | |||
+ | Pour rendre l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl start httpd.service | ||
+ | </ | ||
+ | |||
+ | Vérifiez ensuite l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl is-active httpd.service | ||
+ | active | ||
+ | |||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 34382 (httpd) | ||
+ | | ||
+ | Tasks: 213 (limit: 23719) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jun 06 15:33:05 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc httpd[34382]: | ||
+ | </ | ||
+ | |||
+ | Pour arrêter une Unité de service, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl stop httpd.service | ||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 34382 ExecStart=/ | ||
+ | Main PID: 34382 (code=exited, | ||
+ | | ||
+ | |||
+ | Jun 06 15:33:05 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc httpd[34382]: | ||
+ | Jun 06 23:58:02 centos8.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Jun 06 23:58:04 centos8.ittraining.loc systemd[1]: httpd.service: | ||
+ | Jun 06 23:58:04 centos8.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | Pour désactiver un service au prochain démarrage du système, utilisez l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl disable httpd.service | ||
+ | Removed / | ||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | Jun 06 15:33:05 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 06 15:33:06 centos8.ittraining.loc httpd[34382]: | ||
+ | Jun 06 23:58:02 centos8.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Jun 06 23:58:04 centos8.ittraining.loc systemd[1]: httpd.service: | ||
+ | Jun 06 23:58:04 centos8.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | </ | ||
+ | |||
+ | ===5.2 - Gestion d' | ||
+ | |||
+ | Systemd permet l' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cat / | ||
+ | # This is a template for httpd instances. | ||
+ | # See httpd@.service(8) for more information. | ||
+ | |||
+ | [Unit] | ||
+ | Description=The Apache HTTP Server | ||
+ | After=network.target remote-fs.target nss-lookup.target | ||
+ | Documentation=man: | ||
+ | |||
+ | [Service] | ||
+ | Type=notify | ||
+ | Environment=LANG=C | ||
+ | Environment=HTTPD_INSTANCE=%i | ||
+ | ExecStartPre=/ | ||
+ | ExecStartPre=/ | ||
+ | ExecStart=/ | ||
+ | ExecReload=/ | ||
+ | # Send SIGWINCH for graceful stop | ||
+ | KillSignal=SIGWINCH | ||
+ | KillMode=mixed | ||
+ | PrivateTmp=true | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Une instance créée à partir de ce gabarit devrait avoir un nom sous la forme suivante : | ||
+ | |||
+ | < | ||
+ | httpd@< | ||
+ | </ | ||
+ | |||
+ | Dans ce fichier on peut constater l' | ||
+ | |||
+ | * %n : est remplacé par le nom complet échappé de l' | ||
+ | * %N : est remplacé par le nom complet non-échappé de l' | ||
+ | * %p : est remplacé par le préfixe échappé de l' | ||
+ | * %P : est remplacé par le préfixe non-échappé de l' | ||
+ | * %i : est remplacé par le nom de l' | ||
+ | * %I : est remplacé par le nom de l' | ||
+ | * %f : est remplacé par le préfixe non-échappé ou le nom de l' | ||
+ | * %c : est remplacé par le CGroup de l' | ||
+ | * %u : est remplacé par le nom de l' | ||
+ | * %U : est remplacé par l'UID de l' | ||
+ | * %H : est remplacé par le nom d' | ||
+ | * %% : est remplacé" | ||
+ | |||
+ | Créez maintenant deux copies du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cp / | ||
+ | [root@centos8 ~]# cp / | ||
+ | </ | ||
+ | |||
+ | Créez deux copies du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# cp / | ||
+ | [root@centos8 ~]# cp / | ||
+ | </ | ||
+ | |||
+ | Editez la directive **Listen** du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# vi / | ||
+ | [root@centos8 ~]# more / | ||
+ | # | ||
+ | # This is the main Apache HTTP server configuration file. It contains the | ||
+ | # configuration directives that give the server its instructions. | ||
+ | # See < | ||
+ | # In particular, see | ||
+ | # < | ||
+ | # for a discussion of each configuration directive. | ||
+ | # | ||
+ | # See the httpd.conf(5) man page for more information on this configuration, | ||
+ | # and httpd.service(8) on using and configuring the httpd service. | ||
+ | # | ||
+ | # Do NOT simply read the instructions in here without understanding | ||
+ | # what they do. They' | ||
+ | # consult the online docs. You have been warned. | ||
+ | # | ||
+ | # Configuration and logfile names: If the filenames you specify for many | ||
+ | # of the server' | ||
+ | # server will use that explicit path. If the filenames do *not* begin | ||
+ | # with "/", | ||
+ | # with ServerRoot set to '/ | ||
+ | # server as '/ | ||
+ | # interpreted as '/ | ||
+ | |||
+ | # | ||
+ | # ServerRoot: The top of the directory tree under which the server' | ||
+ | # configuration, | ||
+ | # | ||
+ | # Do not add a slash at the end of the directory path. If you point | ||
+ | # ServerRoot at a non-local disk, be sure to specify a local disk on the | ||
+ | # Mutex directive, if file-based mutexes are used. If you wish to share the | ||
+ | # same ServerRoot for multiple httpd daemons, you will need to change at | ||
+ | # least PidFile. | ||
+ | # | ||
+ | ServerRoot "/ | ||
+ | |||
+ | # | ||
+ | # Listen: Allows you to bind Apache to specific IP addresses and/or | ||
+ | # ports, instead of the default. See also the < | ||
+ | # directive. | ||
+ | # | ||
+ | # Change this to Listen on specific IP addresses as shown below to | ||
+ | # prevent Apache from glomming onto all bound IP addresses. | ||
+ | # | ||
+ | #Listen 12.34.56.78: | ||
+ | Listen 8008 | ||
+ | PidFile / | ||
+ | |||
+ | # | ||
+ | # Dynamic Shared Object (DSO) Support | ||
+ | # | ||
+ | # To be able to use the functionality of a module which was built as a DSO you | ||
+ | # have to place corresponding `LoadModule' | ||
+ | # directives contained in it are actually available _before_ they are used. | ||
+ | # Statically compiled modules (those listed by `httpd -l') do not need | ||
+ | # to be loaded here. | ||
+ | # | ||
+ | # Example: | ||
+ | # LoadModule foo_module modules/ | ||
+ | --More--(19%) | ||
+ | </ | ||
+ | |||
+ | Editez la directive **Listen** du fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# vi / | ||
+ | [root@centos8 ~]# more / | ||
+ | # | ||
+ | # This is the main Apache HTTP server configuration file. It contains the | ||
+ | # configuration directives that give the server its instructions. | ||
+ | # See < | ||
+ | # In particular, see | ||
+ | # < | ||
+ | # for a discussion of each configuration directive. | ||
+ | # | ||
+ | # See the httpd.conf(5) man page for more information on this configuration, | ||
+ | # and httpd.service(8) on using and configuring the httpd service. | ||
+ | # | ||
+ | # Do NOT simply read the instructions in here without understanding | ||
+ | # what they do. They' | ||
+ | # consult the online docs. You have been warned. | ||
+ | # | ||
+ | # Configuration and logfile names: If the filenames you specify for many | ||
+ | # of the server' | ||
+ | # server will use that explicit path. If the filenames do *not* begin | ||
+ | # with "/", | ||
+ | # with ServerRoot set to '/ | ||
+ | # server as '/ | ||
+ | # interpreted as '/ | ||
+ | |||
+ | # | ||
+ | # ServerRoot: The top of the directory tree under which the server' | ||
+ | # configuration, | ||
+ | # | ||
+ | # Do not add a slash at the end of the directory path. If you point | ||
+ | # ServerRoot at a non-local disk, be sure to specify a local disk on the | ||
+ | # Mutex directive, if file-based mutexes are used. If you wish to share the | ||
+ | # same ServerRoot for multiple httpd daemons, you will need to change at | ||
+ | # least PidFile. | ||
+ | # | ||
+ | ServerRoot "/ | ||
+ | |||
+ | # | ||
+ | # Listen: Allows you to bind Apache to specific IP addresses and/or | ||
+ | # ports, instead of the default. See also the < | ||
+ | # directive. | ||
+ | # | ||
+ | # Change this to Listen on specific IP addresses as shown below to | ||
+ | # prevent Apache from glomming onto all bound IP addresses. | ||
+ | # | ||
+ | #Listen 12.34.56.78: | ||
+ | Listen 8009 | ||
+ | PidFile / | ||
+ | # | ||
+ | # Dynamic Shared Object (DSO) Support | ||
+ | # | ||
+ | # To be able to use the functionality of a module which was built as a DSO you | ||
+ | # have to place corresponding `LoadModule' | ||
+ | # directives contained in it are actually available _before_ they are used. | ||
+ | # Statically compiled modules (those listed by `httpd -l') do not need | ||
+ | # to be loaded here. | ||
+ | # | ||
+ | # Example: | ||
+ | # LoadModule foo_module modules/ | ||
+ | --More--(19%) | ||
+ | </ | ||
+ | |||
+ | Démarrez les deux services : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl start httpd@instance01.service | ||
+ | [root@centos8 ~]# systemctl status httpd@instance01.service | ||
+ | ● httpd@instance01.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 43854 ExecStartPre=/ | ||
+ | Process: 43852 ExecStartPre=/ | ||
+ | Main PID: 43856 (httpd) | ||
+ | | ||
+ | Tasks: 213 (limit: 23719) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jun 07 01:40:43 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 07 01:40:43 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 07 01:40:43 centos8.ittraining.loc httpd[43856]: | ||
+ | [root@centos8 ~]# systemctl start httpd@instance02.service | ||
+ | [root@centos8 ~]# systemctl status httpd@instance02.service | ||
+ | ● httpd@instance02.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Process: 43568 ExecStartPre=/ | ||
+ | Process: 43566 ExecStartPre=/ | ||
+ | Main PID: 43569 (httpd) | ||
+ | | ||
+ | Tasks: 213 (limit: 23719) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jun 07 01:36:45 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 07 01:36:45 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 07 01:36:45 centos8.ittraining.loc httpd[43569]: | ||
+ | </ | ||
+ | |||
+ | ===5.3 - Interdire la Modification du Statut d'un Service=== | ||
+ | |||
+ | Il est possible d' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | |||
+ | Jun 07 18:27:25 centos8.ittraining.loc httpd[58535]: | ||
+ | Jun 07 18:27:29 centos8.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Jun 07 18:27:30 centos8.ittraining.loc systemd[1]: httpd.service: | ||
+ | Jun 07 18:27:30 centos8.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | Jun 07 18:27:32 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 07 18:27:32 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 07 18:27:32 centos8.ittraining.loc httpd[58760]: | ||
+ | Jun 07 18:27:34 centos8.ittraining.loc systemd[1]: Stopping The Apache HTTP Server... | ||
+ | Jun 07 18:27:36 centos8.ittraining.loc systemd[1]: httpd.service: | ||
+ | Jun 07 18:27:36 centos8.ittraining.loc systemd[1]: Stopped The Apache HTTP Server. | ||
+ | |||
+ | [root@centos8 ~]# systemctl mask httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@centos8 ~]# systemctl enable httpd.service | ||
+ | Failed to enable unit: Unit file / | ||
+ | |||
+ | [root@centos8 ~]# systemctl start httpd.service | ||
+ | Failed to start httpd.service: | ||
+ | </ | ||
+ | |||
+ | Pour autoriser de nouveau les modifications, | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# systemctl unmask httpd.service | ||
+ | Removed / | ||
+ | |||
+ | [root@centos8 ~]# systemctl enable httpd.service | ||
+ | Created symlink / | ||
+ | |||
+ | [root@centos8 ~]# systemctl start httpd.service | ||
+ | |||
+ | [root@centos8 ~]# systemctl status httpd.service | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 59101 (httpd) | ||
+ | | ||
+ | Tasks: 213 (limit: 23719) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jun 07 18:30:59 centos8.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Jun 07 18:30:59 centos8.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
+ | Jun 07 18:31:00 centos8.ittraining.loc httpd[59101]: | ||
+ | </ | ||
+ | |||
+ | =====Arrêt du Système===== | ||
+ | |||
+ | Sous RHEL / CentOS 8 les commandes **halt**, **poweroff**, | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 / | ||
+ | lrwxrwxrwx. 1 root root 16 Apr 7 16:55 / | ||
+ | </ | ||
+ | |||
+ | La manière recommendée d' | ||
+ | |||
+ | * systemctl halt | ||
+ | * systemctl poweroff | ||
+ | * systemctl reboot | ||
+ | * systemctl shutdown | ||
+ | |||
+ | Il est cependant toujours possibles d' | ||
+ | |||
+ | ====La Commande shutdown==== | ||
+ | |||
+ | Lors de l' | ||
+ | |||
+ | * Il previent les utilisateurs, | ||
+ | * Il arrête tous les services, | ||
+ | * Il inscrit toutes les données sur disque, | ||
+ | * Il démonte les systèmes de fichiers. | ||
+ | |||
+ | La commande utilisée pour arrêter le système est la commande **shutdown** : | ||
+ | |||
+ | shutdown [-t sec] [-HPrhkc] heure [message] | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# shutdown --help | ||
+ | shutdown [OPTIONS...] [TIME] [WALL...] | ||
+ | |||
+ | Shut down the system. | ||
+ | |||
+ | | ||
+ | -H --halt | ||
+ | -P --poweroff | ||
+ | -r --reboot | ||
+ | -h | ||
+ | -k | ||
+ | | ||
+ | -c | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | ^ Valeur ^ Description ^ | ||
+ | | hh:mm | L' | ||
+ | | +m | Nombre de minutes avant que l' | ||
+ | | now | L' | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **Important** : Si l' | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# date && shutdown -t 60 -k | ||
+ | Mon Jun 7 18:58:26 EDT 2021 | ||
+ | Shutdown scheduled for Mon 2021-06-07 18:59:26 EDT, use ' | ||
+ | </ | ||
+ | |||
+ | ==== La Commande reboot==== | ||
+ | |||
+ | Cette commande redémarre le système. | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# reboot --help | ||
+ | reboot [OPTIONS...] [ARG] | ||
+ | |||
+ | Reboot the system. | ||
+ | |||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ==== La Commande halt==== | ||
+ | |||
+ | Cette commande arrête le système. | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# halt --help | ||
+ | halt [OPTIONS...] | ||
+ | |||
+ | Halt the system. | ||
+ | |||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ==== La Commande poweroff==== | ||
+ | |||
+ | Cette commande arrête le système et coupe l' | ||
+ | |||
+ | ===Options de la commande=== | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# poweroff --help | ||
+ | poweroff [OPTIONS...] | ||
+ | |||
+ | Power off the system. | ||
+ | |||
+ | | ||
+ | | ||
+ | -p --poweroff | ||
+ | | ||
+ | -f --force | ||
+ | -w --wtmp-only Don't halt/ | ||
+ | -d --no-wtmp | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ----- | ||
+ | Copyright © 2024 Hugh Norris. |