Ceci est une ancienne révision du document !
Table des matières
Version : 2023.01
Dernière mise-à-jour : 2023/06/08 11:57
Topic 2 : Linux Installation and Package Management
Contenu du Module
- Topic 2 : Linux Installation and Package Management
- Contenu du Module
- BIOS, EFI et OpenFirmware
- Systèmes à base du BIOS
- Charger de Démarrage
- Systèmes à base de l'EFI
- Autres Systèmes
- Gestionnaire d'amorçage
- LILO
- La Commande LILO
- Codes Erreur de LILO
- Grub Legacy sous RHEL/CentOS 6
- Configurer GRUB Legacy
- La Section Globale
- Une Section spécifique à un OS
- Configurer l'Authentification
- Modifier la Configuration de GRUB Legacy en Ligne de Commande
- GRUB 2 sous RHEL/CentOS 7
- Le fichier /boot/grub/device.map
- Le fichier /etc/default/grub
- 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
- Chargeurs de Démarrages Alternatifs
- Systemd-boot
- U-boot
- Le Projet Syslinux
- SYSLINUX
- EXTLINUX
- ISOLINUX
- PXELINUX
- Isodhpfx
- Initramfs sous RHEL/CentOS 6
- Examiner l'image existante
- Le script init
- La Commande dracut
- Initramfs sous RHEL/CentOS 7
- Examiner l'image existante
- Le script init
- Consulter le contenu d'un fichier dans initramfs
- La Commande dracut
- LAB #1 - Compiler à partir des sources
- ./configure
- make
- make check
- make install
- La commande rpm
- Configuration
- LAB #2 - Utilisation
- La commande yum
- Configuration
- Dépôts
- Utilisation
- La Commande yumdownloader
- LAB #3 - Utiliser la commande yum
- Les Bibliothèques Partagées
- Présentation
- Introduction
- Stockage
- ld-linux.so.2
- La Commande ldd
- Le fichier /etc/ld.so.conf
- La Commande ldconfig
- La Commande dpkg
- Configuration
- Utilisation
- La Commande dselect
- La Commande apt-get
- Configuration
- Dépôts
- Utilisation
- LAB #4 - Utiliser la commande apt-get
- LAB #5 - Utiliser la commande apt-cache
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'affichage,
- Détecter les périphériques de stockage,
- Lancer le Charger de Démarrage du système d'exploitation en utilisant le bootstrap loader.
Charger de Démarrage
La première partie du Charger 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'EFI
Depuis 2011, le BIOS est en train d'être remplacé par l'utilisation de l'UEFI (Unified Extensible Firmware Interface ou Interface micrologicielle extensible unifiée) issue du développement de l'EFI conçue par Intel pour les processeurs Itanium..
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'exploitation à lancer dans une partition appelée EFI System Partition ou ESP. Cette partition est normalement montée à /boot/efi sous Linux.
Pour que EFI fonctionne, le micrologiciel (firmware) d'EFI doit avoir connaissance de chaque système d'exploitation à démarrer.
A retenir : Sous Linux c'est l'application efibootmgr qui permet de créer et de supprimer des entrées ainsi que de modifier l'ordre de démarrage.
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.
Autres Systèmes
Les systèmes utilisant des processeurs autre qu'un x86 ou x86-64 utilisent un logiciel tel OpenFirmware.
Gestionnaires de Démarrage
Des gestionnaires d'amorçage sous Linux, un se distingue comme étant le plus utilisé :
- GRUB (Grand Unified Boot Loader)
Cependant il en existe d'autres :
- LILO (LInux LOader)
- SysLinux
- LoadLin
- …
LILO
LILO (LInux LOader) est configuré par le fichier /etc/lilo.conf.
La Commande LILO
La commande lilo peut prendre une de plusieurs options. Les options les plus importantes sont :
Option | Description |
---|---|
-M | Permet d'écrire sur le MBR |
-d | Permet de réduire ou augmenter le temps d'attente avant le lancement du noyau par défaut |
-D | Permet de sélectionner un noyau par défaut en indiquant son label |
-u | Permet de désinstaller LILO |
-v | Permet d'activer le mode verbose |
-m | Permet de modifier le fichier map par défaut (/boot/map) |
-i | Permet de spécifier un nouveau fichier à utiliser comme secteur de boot (/boot/boot.b) |
-C | Permet de modifier le fichier de configuration par défaut |
-q | Permet de créer le fichier /boot/map qui contient l'emplacement des noyaux qui peuvent être booter |
Codes Erreur de LILO
Lors du démarrage, LILO permet d'identifier les éventuelles erreurs :
Affichage | Erreur |
---|---|
(rien) | Aucun morceau de LILO n'a été chargé. Soit LILO n'est pas installé, soit la partition sur laquelle son secteur d'amorce se trouve n'est pas active. |
L | Le premier morceau du chargeur d'amorce a été chargé et démarré, mais il ne peut charger le second morceau. Les codes d'erreur à deux chiffres indiquent le type de problème. (Voir également la section “Codes d'erreur disque”.) Ce cas indique en général une panne de périphérique ou une incohérence de géométrie (c'est à dire de mauvais paramètres disques). |
LI | Le premier morceau du chargeur d'amorce a pu charger le second morceau, mais n'a pas réussi à l'exécuter. Cela peut être causé par une incohérence de géométrie ou par le déplacement de /boot/boot.b sans lancer l'installateur de carte. |
LIL | Le second morceau du chargeur d'amorce a été démarré, mais il ne trouve pas la table de descripteurs dans le fichier carte. C'est en général dû à une panne de périphérique ou une incohérence de géométrie. |
LIL? | Le second morceau du chargeur d'amorce a été chargé à un adresse incorrecte. C'est en général causé par une subtile incohérence de géométrie, ou par le déplacement de /boot/boot.b sans lancer l'installateur de carte. |
LIL- | La table de descripteurs est corrompue. Cela peut être dû à une incohérence de géométrie ou au déplacement de /boot/map sans lancer l'installeur. |
LILO | Tous les éléments de LILO ont été correctement chargés. |
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.
Important : LILO ne gère pas les systèmes UEFI.
Grub Legacy sous RHEL/CentOS 6
A retenir : Grub Legacy a été créé en 1999.
Dans le cas où le Charger de Démarrage grub n'est pas installé, il convient de saisir la commande suivante :
# grub-install /dev/sda [Entrée]
où sda est le nom du périphérique ou grub doit s'installer dans le MBR. Notez cependant que le MBR a une taille trop petite pour contenir tout le Charger de Démarrage. Pour cette raison, le gestionnaire est divisé en deux. Le gestionnaire de niveau 1 est stocké dans le MBR et indique où se trouve le gestionnaire de niveau 2, c'est-à-dire le répertoire /boot.
Il est aussi possible d'utiliser la commande :
# grub-install '(hd0)' [Entrée]
où hd0 indique à grub le premier disque.
Il est à noter que la première partie du Charger de Démarrage peut également être installé dans un PBR (Partition Boot Record) dans le cas d'un système dual-boot voire multi-boot au quel cas on parle de chainloading :
# grub-install /dev/sda1 [Entrée]
ou :
# grub-install 'hd(0,0)' [Entrée]
où (0,0) est la nomenclature grub pour la première partition du premier disque.
Le gestionnaire de niveau 1 a pour seul but le lancement du gestionnaire de niveau 2. Le gestionnaire de niveau 2 charge le noyau en mémoire, monte l'image initrd et charge les modules nécessaires pendant que le noyau monte la partition racine / en lecture seule.
Pour désinstaller grub du MBR, utilisez une disquette DOS pour démarrer la machine puis taper la commande suivante au prompt :
A> fdisk /mbr [Entrée]
Configurer GRUB Legacy
grub se configure grâce au fichier /boot/grub/menu.lst. Pour visualiser ce fichier, il convient de saisir la commande suivante :
[root@centos6 ~]# cat /boot/grub/menu.lst # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS Linux (2.6.32-71.29.1.el6.i686) root (hd0,0) kernel /vmlinuz-2.6.32-71.29.1.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /initramfs-2.6.32-71.29.1.el6.i686.img title centos (2.6.32-71.el6.i686) root (hd0,0) kernel /vmlinuz-2.6.32-71.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /initramfs-2.6.32-71.el6.i686.img
Important : Sous les distributions dérivées de Red Hat, par exemple Fedora, le fichier menu.lst s'appelle grub.conf.
Ce fichier comporte plusieurs sections :
* la section des **paramètres globaux**, * une ou plusieurs sections pour chaque système d'opération installé sur la machine.
La Section Globale
Paramètre | Explication |
---|---|
default=0 | Ce paramètre désigne le numéro de l'entrée à charger par défaut. La valeur de 0 indique la première section commençant par le mot clef title |
timeout=5 | Ce paramètre indique le délai en secondes après lequel l'entrée par défaut sera chargée. |
splashimage=(hd0,0)/grub/splash.xpm.gz | Ce paramètre indique l'emplacement de l'image de fond du menu de GRUB Legacy |
hiddenmenu | Ce paramètre cache le menu de GRUB Legacy pendant le chargement de l'entrée par défaut, sauf si l'utilisateur appuie sur une touche |
color | Ce paramètre prend la forme de deux pairs de couleurs. Le premier, par exemple white/blue, définit les couleurs de l'avant-plan et de l'arrière-plan des entrées normales du menu, tandis que le deuxième, par exemple yellow/blue définit les couleurs de l'avant-plan et de l'arrière-plan des entrées sélectionnées du menu |
password=motdepasse | Cette option n'est présente que dans le cas où un mot de passe a été spécifié pour protéger GRUB Legacy |
Une Section spécifique à un OS
Paramètre | Explication |
---|---|
title CentOS Linux (2.6.32-71.29.1.el6.i686) | Ce paramètre indique le début d'une section de configuration d'une entrée pour un système d'exploitation ainsi que le nom qui apparaît dans le menu de GRUB Legacy |
root (hd0,0) | Ce paramètre indique la partition contenant le noyau de Linux. Dans l'exemple hd0,0 indique la première partition du premier disque dur. Cette partition est ensuite montée en tant que /boot. |
kernel /vmlinuz-2.6.32-71.29.1.el6.i686 | Ce paramètre indique le nom du noyau à charger pour démarrer la machine. Son chemin est relatif à la partition de démarrage (hd0,0). Certaines options peuvent être passées au noyau en les spécifiant en tant qu'arguments telles rhgb ou Red Hat Graphical Boot et quiet qui supprime les messages de démarrage qui apparaissent avant le lancement de l'animation graphique activée par l'option rhgb |
initrd | Ce paramètre stipule l'emplacement du disque initial chargé en mémoire lors du démarrage. Son chemin est relatif à la partition de démarrage (hd0,0). |
lock | |
rootnoverify (hd0,1) | Ce paramètre indique une section concernant un système d'exploitation non Linux, tel que Windows™ |
Configurer l'Authentification
Grub Legacy peut être protéger par un mot de passe en incluant la directive suivante dans le fichier /boot/grub/menu.lst :
password --md5 <mot de passe>
Le mot de passe doit être chiffré avec MD5 :
[root@centos6 ~]# grub-md5-crypt Password: Retype password: $1$VLOzG$ibdk0my4IHny/XtNIGRhv1
Editez ensuite le fichier /boot/grub/menu.lst :
[root@centos6 ~]# cat /boot/grub/menu.lst # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/sda2 # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 password --md5 $1$VLOzG$ibdk0my4IHny/XtNIGRhv1 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.32-504.1.3.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-504.1.3.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-504.1.3.el6.i686.img title CentOS (2.6.32-358.18.1.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-358.18.1.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.18.1.el6.i686.img title CentOS (2.6.32-358.6.1.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-358.6.1.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-358.6.1.el6.i686.img title CentOS (2.6.32-279.el6.i686) lock root (hd0,0) kernel /vmlinuz-2.6.32-279.el6.i686 ro root=UUID=b9f29672-c84e-4d3b-b132-189758a084eb rd_NO_LUKS rd_NO_MD LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=fr-latin9 rd_NO_LVM rd_NO_DM rhgb quiet initrd /initramfs-2.6.32-279.el6.i686.img
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.
Modifier la Configuration de GRUB Legacy en Ligne de Commande
Lors du démarrage de GRUB Legacy, il est possible de voir son menu en appuyant sur n'importe quelle touche. Si GRUB Legacy a été protégé par un mot de passe, il convient d'appuyer sur la touche p puis de rentrer le mot de passe. A ce stade il est possible d'utiliser deux autres touches :
- la touche e pour accéder à l'éditeur de l'interface,
- la touche c pour accéder à la ligne de commande.
En mode édition notez l'utilisation des touches suivantes :
- e : éditer une ligne,
- d : supprimer une ligne,
- o : ajouter une ligne après la ligne courante,
- O : ajouter une ligne avant la ligne courante,
- b : démarrer avec la configuration modifiée,
- echap : abandonner les modifications et retourner à l'interface de GRUB.
GRUB 2 sous RHEL/CentOS 7
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.
Le lancement de GRUB 2 se fait en trois étapes :
- 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 2 : Contenu dans le répertoire /boot/grub2/, 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 :
# grub2-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.
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 :
[root@centos7 ~]# cat /boot/grub2/grub.cfg # # DO NOT EDIT THIS FILE # # It is automatically generated by grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### set pager=1 if [ -s $prefix/grubenv ]; then load_env fi if [ "${next_entry}" ] ; then set default="${next_entry}" set next_entry= save_env next_entry set boot_once=true else set default="${saved_entry}" fi if [ x"${feature_menuentry_id}" = xy ]; then menuentry_id_option="--id" else menuentry_id_option="" fi export menuentry_id_option if [ "${prev_saved_entry}" ]; then set saved_entry="${prev_saved_entry}" save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z "${boot_once}" ]; then saved_entry="${chosen}" 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 /etc/grub.d/00_header ### ### 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 } 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' { 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-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 initrd16 /initramfs-3.10.0-123.el7.x86_64.img } 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' { load_video 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-0-rescue-a2feb9eb09b1488da0f23b99a66350f8 root=UUID=b35de665-5ec8-4226-a533-58a1b567ac91 ro vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet initrd16 /initramfs-0-rescue-a2feb9eb09b1488da0f23b99a66350f8.img } 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 ### ### BEGIN /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 ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # 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. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f ${config_directory}/custom.cfg ]; then source ${config_directory}/custom.cfg elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ###
Prenons le cas des paramètres de Grub Legacy et comparons-les aux paramètres de GRUB 2 :
Grub Legacy | GRUB 2 |
---|---|
title | Menuentry |
root (hd0,0) | set root=hd(0,1). Notez que GRUB 2 commence toujours la numérotation des disques à 0 mais numérote les partitions à partir de 1 |
kernel | linux |
initrd | initrd |
lock | Ce paramètre n'existe plus sous GRUB 2. |
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 :
- grub2-mkconfig -o /boot/grub2/grub.cfg, ou
- grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Lors de l'exécution de la commande grub2-mkconfig plusieurs fichiers sont lus :
Le fichier /boot/grub2/device.map
[root@centos7 ~]# cat /boot/grub2/device.map # this device map was generated by anaconda (hd0) /dev/sda (hd1) /dev/sda
Le fichier /etc/default/grub
Ce fichier contient la configuration par défaut des paramètres de GRUB 2 :
[root@centos7 ~]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="vconsole.keymap=fr crashkernel=auto vconsole.font=latarcyrheb-sun16 rhgb quiet" GRUB_DISABLE_RECOVERY="true"
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.
Dans ce fichier les directives sont :
Directive | Description |
---|---|
GRUB_DEFAULT | Entrée du menu sélectionner par défaut |
GRUB_TIMEOUT | Durée de l'affichage du menu avant le démarrage en utilisant la valeur de GRUB_DEFAULT |
GRUB_DISTRIBUTOR | Ligne de commande qui génère le texte de l'entrée |
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_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_DISABLE_LINUX_UUID | Si true, cette directive empêche l'utilisation de l'UUID de la partition |
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_BADRAM | Permet de spécifier de la mémoire défaillante |
Les fichiers du répertoire /etc/grub.d
Les fichiers de ce répertoire sont exécutés dans l'ordre alphanumérique et servent à construire les menus de GRUB 2 :
[root@centos7 ~]# ls -l /etc/grub.d total 68 -rwxr-xr-x. 1 root root 8702 Mar 26 09:27 00_header -rwxr-xr-x. 1 root root 992 Oct 17 2014 00_tuned -rwxr-xr-x. 1 root root 10114 Mar 26 09:27 10_linux -rwxr-xr-x. 1 root root 10275 Mar 26 09:27 20_linux_xen -rwxr-xr-x. 1 root root 2559 Mar 26 09:27 20_ppc_terminfo -rwxr-xr-x. 1 root root 11169 Mar 26 09:27 30_os-prober -rwxr-xr-x. 1 root root 214 Mar 26 09:27 40_custom -rwxr-xr-x. 1 root root 216 Mar 26 09:27 41_custom -rw-r--r--. 1 root root 483 Mar 26 09:27 README
- Le fichier /etc/grub.d/10_Linux,
- Le fichier 10_Linux contient des boucles pour rechercher des noyaux Linux,
- Le fichier /etc/grub.d/30_os-prober,
- Ce fichier recherche des éventuels systèmes d'exploitation autre que Linux,
- Les fichiers /etc/grub.d/40_custom et /etc/grub.d/41_custom,
- 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 :
[root@centos7 ~]# touch /etc/grub.d/01_users [root@centos7 ~]# chmod 755 /etc/grub.d/01_users
Créez deux mots de passe hashés au format PBKDF2 en utilisant la commande grub2-mkpasswd-pbkdf2 sous RHEL/CentOS :
[root@centos7 ~]# grub2-mkpasswd-pbkdf2 Enter password: pass123 Reenter password: pass123 PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD
Editez le fichier /etc/grub.d/01_users ainsi :
- /etc/grub.d/01_users
#!/bin/sh -e cat <<EOF set superusers="root" password_pbkdf2 root grub.pbkdf2.sha512.10000.0298C1C613A451C46FBC95BB2AC7A41BCEC1C61512EF785BD81E3B65DFF9D57ED4ADF8906C3EF33C22C06FBDD366E1C118FC41110BD646A4D49EF86EFD0573BF.E14A45900096D773BE99BEA9AB8D4FA81431458952798B997D4FC9E0850426F6798979371B8EBD331DB33AE8FEAE25E6773156D42F21B884DBA405546782B3BD EOF
Il est aussi possible d'utiliser des mots de passe non cryptés. Modifiez donc le fichier /etc/grub.d/01_users ainsi :
- /etc/grub.d/01_users
#!/bin/sh -e cat <<EOF set superusers="root" password root pass123 EOF
Sous RHEL/CentOS, lancez la commande grub2-mkconfig -o /boot/grub2/grub.cfg :
[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
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&é“ ).
RHEL/CentOS >= 7.2
Depuis la version 7.2 de RHEL/centOS le fichier /etc/grub.d/01_users existe déjà :
[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
Ce script est évidement présent dans le fichier grub.cfg :
### 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 ###
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 :
[root@centos7 ~]# grub2-setpassword Enter password: pass123 Confirm password: pass123
Consultez maintenant le fichier /boot/grub2/user.cfg :
[root@centos7 ~]# cat /boot/grub2/user.cfg GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.3DD268A626FC781A0693D381A5F1BBDE6C834D1D904F023AED8CEF2985304FEC9F0C1C8B975156F5DF534F4B10BCCDC5C187B0C12F55E970A244D9EF2EF962DD.9BB2011598B8E5EFD9A464ED96C0FECB8DCD8FD6942E5114E035AD8A9E2DCFF32A9DC1C222B4226A462B32E7B6D80247F96D79133F18F6524544984837EF4D06
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.
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 :
[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 } ...
[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 } ...
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.
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'exploitation en le sélectionnant avec les flèches puis en appuyant sur la touche ↵ Entrée,
- Lancer l'éditeur en appuyant sur la touche e,
- Lancer l’interface de la ligne de commande GRUB en appuyant sur la touche c.
En mode édition notez l'utilisation des touches suivantes :
- flèches : se déplacer dans l'écran. L'édition se fait en utilisant simplement les touches du clavier,
- Crtl-X : démarrer avec la configuration modifiée,
- echap : abandonner les modifications et retourner à l'interface menu de GRUB 2.
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.
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'importe quelle image à partir de n'importe quel support.
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, deux fichiers sont necéssaires :
- isolinux.bin qui contient l'image du Chargeur de Démarrage et
- 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) qui utilise :
- DHCP pour attribuer une adresse IP à la machine et
- BOOTP pour charger l'image du Chargeur de Démarrage à partir du serveur en utilisant le protocol TFTP (Trivial File Transfer Protocol). L'image à télécharger doit s'appeler /tftpboot/pxelinux.0 et chaque machine doit avoir un fichier de configuration dans le répertoire /tftpboot/pxelinux.cfg/
Isodhpfx
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
Un fichier Initramfs INITial Ram File System est une image d'un système minimal initialisée au démarrage du système.
Ce fichier utilise le système de fichier cramFS qui est un système de fichier compressé au format gzip et archivé via cpio.
L'image est chargée en mémoire vive et permet ainsi d'avoir un système minimal pouvant ensuite charger le système de fichier principal.
Examiner l'image existante
Pour examiner une image initramfs, il convient d'abord de la copier vers /tmp et de la décompresser :
[root@centos6 ~]# cp /boot/initramfs-2.6.32-71.29.1.el6.i686.img /tmp/custom.gz [root@centos6 ~]# gunzip /tmp/custom.gz
Ensuite il convient d'extraire l'image grâce à la commande cpio :
[root@centos6 ~]# cd /tmp [root@centos6 tmp]# mkdir initrd [root@centos6 tmp]# cd initrd [root@centos6 initrd]# cpio -cid -I ../custom 59631 blocs
Installez maintenant le paquet tree :
[root@centos6 initrd]# yum install tree
Utilisez maintenant la commande tree pour examiner le contenu de l'image :
[root@centos6 initrd]# tree | more . ├── bin │ ├── basename │ ├── cat │ ├── cp │ ├── dash │ ├── dd │ ├── dmesg │ ├── grep │ ├── gzip │ ├── ln │ ├── loadkeys │ ├── ls │ ├── mkdir │ ├── mknod │ ├── mount │ ├── mv │ ├── plymouth │ ├── plymouthd │ ├── readlink │ ├── rm │ ├── sed │ ├── setfont │ ├── sh -> dash │ ├── sleep │ ├── umount │ └── uname ├── cmdline --Plus--
Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste :
[root@centos6 initrd]# ls bin dev emergency init initqueue-finished lib pre-pivot pre-udev sbin sysroot usr cmdline dracut-004-33.2.el6_0 etc initqueue initqueue-settled mount pre-trigger proc sys tmp var
A faire : Utilisez le manuel de la commande cpio pour comprendre les options utilisées.
Le script init
Le script init est lancé lors du chargement de l'image :
[root@centos6 initrd]# more init #!/bin/sh # # Licensed under the GPLv2 # # Copyright 2008-2009, Red Hat, Inc. # Harald Hoyer <harald@redhat.com> # Jeremy Katz <katzj@redhat.com> wait_for_loginit() { if getarg rdinitdebug; then set +x exec 0<>/dev/console 1<>/dev/console 2<>/dev/console # wait for loginit i=0 while [ $i -lt 10 ]; do j=$(jobs) [ -z "$j" ] && break [ -z "${j##*Running*}" ] || break sleep 0.1 i=$(($i+1)) done [ $i -eq 10 ] && kill %1 >/dev/null 2>&1 while pidof -x /sbin/loginit >/dev/null 2>&1; do for pid in $(pidof -x /sbin/loginit); do kill $HARD $pid >/dev/null 2>&1 done --Plus--(8%)
A faire : Passez en revue le contenu du script.
La Commande dracut
La commande dracut permet de créer facilement une image initramfs. Les options de la commande sont :
[root@centos6 initrd]# dracut --help Usage: /sbin/dracut [OPTION]... <initramfs> <kernel-version> Creates initial ramdisk images for preloading modules -f, --force Overwrite existing initramfs file. -m, --modules [LIST] Specify a space-separated list of dracut modules to call when building the initramfs. Modules are located in /usr/share/dracut/modules.d. -o, --omit [LIST] Omit a space-separated list of dracut modules. -a, --add [LIST] Add a space-separated list of dracut modules. -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. --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 --strip Strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs (default) --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 -h, --help This message --debug Output debug information of the build process -v, --verbose Verbose output during the build process -c, --conf [FILE] Specify configuration file to use. Default: /etc/dracut.conf -l, --local Local mode. Use modules from the current working directory instead of the system-wide installed in /usr/share/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. -i, --include [SOURCE] [TARGET] Include the files in the SOURCE directory into the Target directory in the final initramfs. -I, --install [LIST] Install the space separated list of files into the initramfs.
Le fichier de configuration de dracut est /etc/dracut.conf :
[root@centos6 initrd]# cat /etc/dracut.conf # Sample dracut config file # Specific list of dracut modules to use #dracutmodules+="" # Dracut modules to omit #omit_dracutmodules+="" # Dracut modules to add to the default #add_dracutmodules+="" # additional kernel modules to the default add_drivers+="" # list of kernel filesystem modules to be included in the generic initramfs #filesystems+="" # build initrd only to boot current hardware #hostonly="yes" # # install local /etc/mdadm.conf mdadmconf="yes" # install local /etc/lvm/lvm.conf lvmconf="yes"
Exécutez maintenant la commande suivante afin de générer le fichier initramfs :
# dracut -v initramfs [Entrée]
Notez la présence de votre nouvelle image /tmp/initrd/initramfs.
Déplacez votre fichier initramfs au répertoire /boot :
[root@centos6 initrd]# mv initramfs /boot
Editez maintenant votre fichier /boot/grub/menu.lst et ajoutez une nouvelle section qui utilise votre initramfs.
... splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS Linux (initramfs) root (hd0,0) kernel /vmlinuz-2.6.32-71.29.1.el6.i686 ro root=UUID=e73735d6-c14b-4a40-8735-f34fc868da8a rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=fr_FR.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fr-latin9 crashkernel=auto rhgb quiet initrd /initramfs title CentOS Linux (2.6.32-71.29.1.el6.i686) ...
A faire : Re-démarrez votre machine pour tester votre configuration.
Initramfs sous RHEL/CentOS 7
Le fichier Initramfs INITial Ram File System est une archive au format cpio compressé :
[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
Examiner l'image existante
Pour examiner une image initramfs archivée, il convient d'utiliser la commande lsinitrd :
[root@centos7 initramfs]# cd .. [root@centos7 tmp]# lsinitrd custom | more Image: custom: 56M ======================================================================== Version: dracut-033-502.el7_4.1 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 0 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 2 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--
Comme vous pouvez le constater, l'image contient une arborescence Linux minimaliste :
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 :
[root@centos7 tmp]# lsinitrd custom | grep init ... lrwxrwxrwx. 1 root root 23 Dec 4 11:00 init -> usr/lib/systemd/systemd ...
Consulter le contenu d'un fichier dans initramfs
Pour consulter le contenu d'un fichier inclus dans l'initramfs, il convient d'utiliser la commande lsinitrd de la manière suivante :
[root@centos7 tmp]# lsinitrd /boot/initramfs-$(uname -r).img /etc/ld.so.conf include ld.so.conf.d/*.conf
La Commande dracut
La commande dracut permet de créer facilement une image initramfs. Les options de la commande sont :
[root@centos7 tmp]# dracut --help Usage: /sbin/dracut [OPTION]... [<initramfs> [<kernel-version>]] Version: 033-463.el7 Creates initial ramdisk images for preloading modules --kver [VERSION] Set kernel version to [VERSION]. -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. For example: # dracut --add-drivers "module1 module2" ...
Le fichier de configuration de dracut est /etc/dracut.conf :
# PUT YOUR CONFIG HERE OR IN separate files named *.conf # in /etc/dracut.conf.d # SEE man dracut.conf(5) # Sample dracut config file #logfile=/var/log/dracut.log #fileloglvl=6 # Exact list of dracut modules to use. Modules not listed here are not going # to be included. If you only want to add some optional modules use # add_dracutmodules option instead. #dracutmodules+="" # dracut modules to omit #omit_dracutmodules+="" # dracut modules to add to the default #add_dracutmodules+="" # additional kernel modules to the default add_drivers+="ehci-hcd ohci-hcd usb-storage scsi_mod sd_mod" # list of kernel filesystem modules to be included in the generic initramfs #filesystems+="" # build initrd only to boot current hardware #hostonly="yes" # # install local /etc/mdadm.conf #mdadmconf="no" # install local /etc/lvm/lvm.conf #lvmconf="no" # A list of fsck tools to install. If it's not specified, module's hardcoded # 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
Exécutez maintenant la commande suivante afin de générer le fichier initramfs :
[root@centos7 tmp]# dracut -v initramfs Executing: /sbin/dracut -v initramfs dracut module 'busybox' will not be installed, because command 'busybox' could not be found! dracut module 'busybox' will not be installed, because command 'busybox' could not be found! *** Including module: bash *** *** Including module: nss-softokn *** *** Including module: i18n *** *** Including module: network *** *** Including module: ifcfg *** *** Including module: drm *** *** Including module: plymouth *** *** Including module: kernel-modules *** *** Including module: qemu *** *** Including module: resume *** *** Including module: rootfs-block *** *** Including module: terminfo *** *** Including module: udev-rules *** Skipping udev rule: 91-permissions.rules *** Including module: biosdevname *** *** Including module: systemd *** *** Including module: usrmount *** *** 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 ***
Notez la présence de votre nouvelle image /tmp/initrd/initramfs :
[root@centos7 initrd]# ls -l /tmp/initrd/initramfs -rw-------. 1 root root 16373488 Jun 10 10:23 /tmp/initrd/initramfs
Déplacez votre fichier initramfs au répertoire /boot :
[root@centos7 initrd]# mv initramfs /boot
Ouvrez votre fichier /boot/grub2/grub.cfg et cherchez la section 10_linux. Copiez la première section menuentry :
... ### 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 } ...
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 :
#!/bin/sh -e 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' { 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 initrd16 /initramfs } EOF
Rendez ce fichier exécutable :
[root@centos7 initrd]# chmod +x /etc/grub.d/09_redhat
Avant de continuer, supprimer le fichier /etc/grub.d/01_users et éditez le contenu du fichier /etc/grub.d/40_custom ainsi :
#!/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.
Mettez à jour grub afin que celui-ci prend en compte le nouveau fichier :
[root@centos7 initrd]# 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
Controlez le fichier /boot/grub2/grub.cfg :
... ### BEGIN /etc/grub.d/09_redhat ### 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' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' 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 else ...
A faire : Re-démarrez votre machine pour tester votre configuration.
LAB #1 - Compiler à partir des sources
Historiquement il était nécessaire d'installer un logiciel à partir de ses fichiers sources.
Pour comprendre ce qui est la compilation d'un logiciel, commencez par télécharger le logiciel hello :
[root@centos7 ~]# wget https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz --2018-07-16 11:10:26-- https://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz Résolution de ftp.gnu.org (ftp.gnu.org)… 208.118.235.20 Connexion à ftp.gnu.org (ftp.gnu.org)|208.118.235.20|:443… connecté. requête HTTP transmise, en attente de la réponse… 200 OK Taille : 389363 (380K) [application/x-gzip] Enregistre : «hello-2.1.1.tar.gz» hello-2.1.1.tar.gz 100%[===========================================================>] 380,24K 946KB/s ds 0,4s 2018-07-16 11:10:27 (946 KB/s) - «hello-2.1.1.tar.gz» enregistré [389363/389363]
Ensuite désarchivez le logiciel :
[root@centos7 ~]# tar xvf hello-2.1.1.tar.gz hello-2.1.1/ hello-2.1.1/intl/ hello-2.1.1/intl/ChangeLog hello-2.1.1/intl/Makefile.in hello-2.1.1/intl/config.charset hello-2.1.1/intl/locale.alias hello-2.1.1/intl/ref-add.sin hello-2.1.1/intl/ref-del.sin hello-2.1.1/intl/gmo.h hello-2.1.1/intl/gettextP.h hello-2.1.1/intl/hash-string.h hello-2.1.1/intl/plural-exp.h hello-2.1.1/intl/eval-plural.h hello-2.1.1/intl/os2compat.h hello-2.1.1/intl/libgnuintl.h hello-2.1.1/intl/loadinfo.h hello-2.1.1/intl/bindtextdom.c hello-2.1.1/intl/dcgettext.c hello-2.1.1/intl/dgettext.c hello-2.1.1/intl/gettext.c hello-2.1.1/intl/finddomain.c hello-2.1.1/intl/loadmsgcat.c hello-2.1.1/intl/localealias.c hello-2.1.1/intl/textdomain.c hello-2.1.1/intl/l10nflist.c hello-2.1.1/intl/explodename.c hello-2.1.1/intl/dcigettext.c hello-2.1.1/intl/dcngettext.c hello-2.1.1/intl/dngettext.c hello-2.1.1/intl/ngettext.c hello-2.1.1/intl/plural.y hello-2.1.1/intl/plural-exp.c hello-2.1.1/intl/localcharset.c hello-2.1.1/intl/localename.c hello-2.1.1/intl/osdep.c hello-2.1.1/intl/os2compat.c hello-2.1.1/intl/intl-compat.c hello-2.1.1/intl/plural.c hello-2.1.1/intl/VERSION hello-2.1.1/po/ hello-2.1.1/po/Makefile.in.in hello-2.1.1/po/Makevars hello-2.1.1/po/remove-potcdate.sin hello-2.1.1/po/quot.sed hello-2.1.1/po/boldquot.sed hello-2.1.1/po/en@quot.header hello-2.1.1/po/en@boldquot.header hello-2.1.1/po/insert-header.sin hello-2.1.1/po/Rules-quot hello-2.1.1/po/POTFILES.in hello-2.1.1/po/hello.pot hello-2.1.1/po/ca.po hello-2.1.1/po/da.po hello-2.1.1/po/de.po hello-2.1.1/po/de_DE.po hello-2.1.1/po/el.po hello-2.1.1/po/eo.po hello-2.1.1/po/es.po hello-2.1.1/po/et.po hello-2.1.1/po/fi.po hello-2.1.1/po/fr.po hello-2.1.1/po/gl.po hello-2.1.1/po/he.po hello-2.1.1/po/hr.po hello-2.1.1/po/hu.po hello-2.1.1/po/id.po hello-2.1.1/po/it.po hello-2.1.1/po/ja.po hello-2.1.1/po/ko.po hello-2.1.1/po/lv.po hello-2.1.1/po/nb.po hello-2.1.1/po/nl.po hello-2.1.1/po/nn.po hello-2.1.1/po/pl.po hello-2.1.1/po/pt.po hello-2.1.1/po/pt_BR.po hello-2.1.1/po/ru.po hello-2.1.1/po/sk.po hello-2.1.1/po/sl.po hello-2.1.1/po/sv.po hello-2.1.1/po/tr.po hello-2.1.1/po/uk.po hello-2.1.1/po/ca.gmo hello-2.1.1/po/da.gmo hello-2.1.1/po/de.gmo hello-2.1.1/po/de_DE.gmo hello-2.1.1/po/el.gmo hello-2.1.1/po/eo.gmo hello-2.1.1/po/es.gmo hello-2.1.1/po/et.gmo hello-2.1.1/po/fi.gmo hello-2.1.1/po/fr.gmo hello-2.1.1/po/gl.gmo hello-2.1.1/po/he.gmo hello-2.1.1/po/hr.gmo hello-2.1.1/po/hu.gmo hello-2.1.1/po/id.gmo hello-2.1.1/po/it.gmo hello-2.1.1/po/ja.gmo hello-2.1.1/po/ko.gmo hello-2.1.1/po/lv.gmo hello-2.1.1/po/nb.gmo hello-2.1.1/po/nl.gmo hello-2.1.1/po/nn.gmo hello-2.1.1/po/pl.gmo hello-2.1.1/po/pt.gmo hello-2.1.1/po/pt_BR.gmo hello-2.1.1/po/ru.gmo hello-2.1.1/po/sk.gmo hello-2.1.1/po/sl.gmo hello-2.1.1/po/sv.gmo hello-2.1.1/po/tr.gmo hello-2.1.1/po/uk.gmo hello-2.1.1/po/ChangeLog hello-2.1.1/po/LINGUAS hello-2.1.1/README hello-2.1.1/ABOUT-NLS hello-2.1.1/AUTHORS hello-2.1.1/COPYING hello-2.1.1/ChangeLog hello-2.1.1/INSTALL hello-2.1.1/Makefile.am hello-2.1.1/Makefile.in hello-2.1.1/NEWS hello-2.1.1/THANKS hello-2.1.1/TODO hello-2.1.1/aclocal.m4 hello-2.1.1/config.guess hello-2.1.1/config.h.in hello-2.1.1/config.rpath hello-2.1.1/config.sub hello-2.1.1/configure hello-2.1.1/configure.ac hello-2.1.1/depcomp hello-2.1.1/install-sh hello-2.1.1/missing hello-2.1.1/mkinstalldirs hello-2.1.1/BUGS hello-2.1.1/ChangeLog.O hello-2.1.1/contrib/ hello-2.1.1/contrib/ChangeLog hello-2.1.1/contrib/Makefile.am hello-2.1.1/contrib/Makefile.in hello-2.1.1/contrib/de_franconian_po.txt hello-2.1.1/contrib/evolution.txt hello-2.1.1/contrib/hello.1 hello-2.1.1/doc/ hello-2.1.1/doc/gpl.texi hello-2.1.1/doc/ChangeLog hello-2.1.1/doc/Makefile.am hello-2.1.1/doc/Makefile.in hello-2.1.1/doc/mdate-sh hello-2.1.1/doc/stamp-vti hello-2.1.1/doc/texinfo.tex hello-2.1.1/doc/version.texi hello-2.1.1/doc/hello.texi hello-2.1.1/doc/hello.info hello-2.1.1/src/ hello-2.1.1/src/ChangeLog hello-2.1.1/src/Makefile.am hello-2.1.1/src/Makefile.in hello-2.1.1/src/alloca.c hello-2.1.1/src/hello.c hello-2.1.1/src/version.c hello-2.1.1/src/getopt.c hello-2.1.1/src/getopt1.c hello-2.1.1/src/getopt.h hello-2.1.1/src/system.h hello-2.1.1/man/ hello-2.1.1/man/ChangeLog hello-2.1.1/man/Makefile.am hello-2.1.1/man/Makefile.in hello-2.1.1/man/hello.1 hello-2.1.1/man/help2man hello-2.1.1/m4/ hello-2.1.1/m4/README hello-2.1.1/m4/ChangeLog hello-2.1.1/m4/Makefile.am hello-2.1.1/m4/Makefile.in hello-2.1.1/m4/codeset.m4 hello-2.1.1/m4/gettext.m4 hello-2.1.1/m4/glibc21.m4 hello-2.1.1/m4/iconv.m4 hello-2.1.1/m4/isc-posix.m4 hello-2.1.1/m4/lcmessage.m4 hello-2.1.1/m4/lib-ld.m4 hello-2.1.1/m4/lib-link.m4 hello-2.1.1/m4/lib-prefix.m4 hello-2.1.1/m4/progtest.m4 hello-2.1.1/tests/ hello-2.1.1/tests/ChangeLog hello-2.1.1/tests/Makefile.am hello-2.1.1/tests/Makefile.in hello-2.1.1/tests/hello-1 hello-2.1.1/tests/world-1 hello-2.1.1/tests/nothing-1
Changez de répertoire :
[root@centos7 ~]# cd hello-2.1.1/
A l'étude du fichier README, celui-ci nous renvoie vers le fichier INSTALL. Visualisez donc ce dernier :
[root@centos7 hello-2.1.1]# more INSTALL Copyright 1994, 1995, 1996, 1999, 2000, 2001 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) --Plus--(11%)
La procédure expliquée est celle utilisée pour la plupart des installations manuelles, à savoir la saisie des quatre commandes suivantes.
./configure
Important : configure est un script chargé de créer les makefiles pour une architecture donnée. Les makefiles sont lus par la commande make.
[root@centos7 hello-2.1.1]# ./configure checking for a BSD-compatible install... /bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets ${MAKE}... yes checking for gcc... gcc checking for C compiler default output... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for strerror in -lcposix... no checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for string.h... (cached) yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking sys/file.h usability... yes checking sys/file.h presence... yes checking for sys/file.h... yes checking sys/param.h usability... yes checking sys/param.h presence... yes checking for sys/param.h... yes checking for working alloca.h... yes checking for alloca... yes checking for struct stat.st_blksize... yes checking for msgfmt... /bin/msgfmt checking for gmsgfmt... /bin/msgfmt checking for xgettext... /bin/xgettext checking for msgmerge... /bin/msgmerge checking build system type... x86_64-unknown-linux checking host system type... x86_64-unknown-linux checking for ranlib... ranlib checking for gcc option to accept ANSI C... none needed checking for an ANSI C-conforming const... yes checking for inline... inline checking for off_t... yes checking for size_t... yes checking for stdlib.h... (cached) yes checking for unistd.h... (cached) yes checking for getpagesize... yes checking for working mmap... yes checking whether we are using the GNU C Library 2.1 or newer... yes checking for ld used by GCC... /bin/ld checking if the linker (/bin/ld) is GNU ld... yes checking for shared library run path origin... done checking for iconv... yes checking argz.h usability... yes checking argz.h presence... yes checking for argz.h... yes checking limits.h usability... yes checking limits.h presence... yes checking for limits.h... yes checking locale.h usability... yes checking locale.h presence... yes checking for locale.h... yes checking nl_types.h usability... yes checking nl_types.h presence... yes checking for nl_types.h... yes checking malloc.h usability... yes checking malloc.h presence... yes checking for malloc.h... yes checking stddef.h usability... yes checking stddef.h presence... yes checking for stddef.h... yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking for unistd.h... (cached) yes checking for sys/param.h... (cached) yes checking for feof_unlocked... yes checking for fgets_unlocked... yes checking for getc_unlocked... yes checking for getcwd... yes checking for getegid... yes checking for geteuid... yes checking for getgid... yes checking for getuid... yes checking for mempcpy... yes checking for munmap... yes checking for putenv... yes checking for setenv... yes checking for setlocale... yes checking for stpcpy... yes checking for strcasecmp... yes checking for strdup... yes checking for strtoul... yes checking for tsearch... yes checking for __argz_count... yes checking for __argz_stringify... yes checking for __argz_next... yes checking for iconv declaration... extern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); checking for nl_langinfo and CODESET... yes checking for LC_MESSAGES... yes checking for bison... no checking whether NLS is requested... yes checking whether included gettext is requested... no checking for GNU gettext in libc... yes checking for perl... perl configure: creating ./config.status config.status: creating Makefile config.status: creating contrib/Makefile config.status: creating doc/Makefile config.status: creating intl/Makefile config.status: creating man/Makefile config.status: creating po/Makefile.in config.status: creating m4/Makefile config.status: creating src/Makefile config.status: creating tests/Makefile config.status: creating config.h config.status: executing depfiles commands config.status: executing default-1 commands config.status: creating po/POTFILES config.status: creating po/Makefile config.status: executing default commands
make
Important : make sert à appeler des commandes créant des fichiers nécessaires à l'installation du logiciel.
[root@centos7 hello-2.1.1]# make make all-recursive make[1]: Entering directory `/root/hello-2.1.1' Making all in contrib make[2]: Entering directory `/root/hello-2.1.1/contrib' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/contrib' Making all in doc make[2]: Entering directory `/root/hello-2.1.1/doc' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/doc' Making all in intl make[2]: Entering directory `/root/hello-2.1.1/intl' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/intl' Making all in po make[2]: Entering directory `/root/hello-2.1.1/po' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/po' Making all in src make[2]: Entering directory `/root/hello-2.1.1/src' source='hello.c' object='hello.o' libtool=no \ depfile='.deps/hello.Po' tmpdepfile='.deps/hello.TPo' \ depmode=gcc3 /bin/sh ../depcomp \ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl -g -O2 -c `test -f 'hello.c' || echo './'`hello.c source='version.c' object='version.o' libtool=no \ depfile='.deps/version.Po' tmpdepfile='.deps/version.TPo' \ depmode=gcc3 /bin/sh ../depcomp \ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl -g -O2 -c `test -f 'version.c' || echo './'`version.c source='getopt.c' object='getopt.o' libtool=no \ depfile='.deps/getopt.Po' tmpdepfile='.deps/getopt.TPo' \ depmode=gcc3 /bin/sh ../depcomp \ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl -g -O2 -c `test -f 'getopt.c' || echo './'`getopt.c source='getopt1.c' object='getopt1.o' libtool=no \ depfile='.deps/getopt1.Po' tmpdepfile='.deps/getopt1.TPo' \ depmode=gcc3 /bin/sh ../depcomp \ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. -I. -I.. -I../intl -I../intl -g -O2 -c `test -f 'getopt1.c' || echo './'`getopt1.c gcc -g -O2 -o hello hello.o version.o getopt.o getopt1.o make[2]: Leaving directory `/root/hello-2.1.1/src' Making all in man make[2]: Entering directory `/root/hello-2.1.1/man' perl help2man --name="Friendly Greeting Program" ../src/hello >hello.1 make[2]: Leaving directory `/root/hello-2.1.1/man' Making all in m4 make[2]: Entering directory `/root/hello-2.1.1/m4' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/m4' Making all in tests make[2]: Entering directory `/root/hello-2.1.1/tests' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/hello-2.1.1/tests' make[2]: Entering directory `/root/hello-2.1.1' make[2]: Leaving directory `/root/hello-2.1.1' make[1]: Leaving directory `/root/hello-2.1.1'
make check
Important : make check permet de vérifier si la commande make a bien fonctionné.
[root@centos7 hello-2.1.1]# make check Making check in contrib make[1]: Entering directory `/root/hello-2.1.1/contrib' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/contrib' Making check in doc make[1]: Entering directory `/root/hello-2.1.1/doc' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/doc' Making check in intl make[1]: Entering directory `/root/hello-2.1.1/intl' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/intl' Making check in po make[1]: Entering directory `/root/hello-2.1.1/po' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/po' Making check in src make[1]: Entering directory `/root/hello-2.1.1/src' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/src' Making check in man make[1]: Entering directory `/root/hello-2.1.1/man' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/man' Making check in m4 make[1]: Entering directory `/root/hello-2.1.1/m4' make[1]: Nothing to be done for `check'. make[1]: Leaving directory `/root/hello-2.1.1/m4' Making check in tests make[1]: Entering directory `/root/hello-2.1.1/tests' make check-TESTS make[2]: Entering directory `/root/hello-2.1.1/tests' PASS: hello-1 PASS: world-1 PASS: nothing-1 ================== All 3 tests passed ================== make[2]: Leaving directory `/root/hello-2.1.1/tests' make[1]: Leaving directory `/root/hello-2.1.1/tests' make[1]: Entering directory `/root/hello-2.1.1' make[1]: Leaving directory `/root/hello-2.1.1'
make install
Important : make install sert à installer le logiciel.
[root@centos7 hello-2.1.1]# make install Making install in contrib make[1]: Entering directory `/root/hello-2.1.1/contrib' make[2]: Entering directory `/root/hello-2.1.1/contrib' make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/root/hello-2.1.1/contrib' make[1]: Leaving directory `/root/hello-2.1.1/contrib' Making install in doc make[1]: Entering directory `/root/hello-2.1.1/doc' make[2]: Entering directory `/root/hello-2.1.1/doc' make[2]: Nothing to be done for `install-exec-am'. /bin/sh ../mkinstalldirs /usr/local/info mkdir -p -- /usr/local/info /bin/install -c -m 644 ./hello.info /usr/local/info/hello.info install-info --info-dir=/usr/local/info /usr/local/info/hello.info make[2]: Leaving directory `/root/hello-2.1.1/doc' make[1]: Leaving directory `/root/hello-2.1.1/doc' Making install in intl make[1]: Entering directory `/root/hello-2.1.1/intl' if test "hello" = "gettext" \ && test '' = 'intl-compat.o'; then \ /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib /usr/local/include; \ /bin/install -c -m 644 libintl.h /usr/local/include/libintl.h; \ @LIBTOOL@ --mode=install \ /bin/install -c -m 644 libintl.a /usr/local/lib/libintl.a; \ else \ : ; \ fi if test 'no' = yes; then \ test yes != no || /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/lib; \ temp=/usr/local/lib/t-charset.alias; \ dest=/usr/local/lib/charset.alias; \ if test -f /usr/local/lib/charset.alias; then \ orig=/usr/local/lib/charset.alias; \ sed -f ref-add.sed $orig > $temp; \ /bin/install -c -m 644 $temp $dest; \ rm -f $temp; \ else \ if test yes = no; then \ orig=charset.alias; \ sed -f ref-add.sed $orig > $temp; \ /bin/install -c -m 644 $temp $dest; \ rm -f $temp; \ fi; \ fi; \ /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/locale; \ test -f /usr/local/share/locale/locale.alias \ && orig=/usr/local/share/locale/locale.alias \ || orig=./locale.alias; \ temp=/usr/local/share/locale/t-locale.alias; \ dest=/usr/local/share/locale/locale.alias; \ sed -f ref-add.sed $orig > $temp; \ /bin/install -c -m 644 $temp $dest; \ rm -f $temp; \ else \ : ; \ fi if test "hello" = "gettext"; then \ /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/intl; \ /bin/install -c -m 644 VERSION /usr/local/share/gettext/intl/VERSION; \ /bin/install -c -m 644 ChangeLog.inst /usr/local/share/gettext/intl/ChangeLog; \ dists="COPYING.LIB-2.0 COPYING.LIB-2.1 Makefile.in config.charset locale.alias ref-add.sin ref-del.sin gmo.h gettextP.h hash-string.h plural-exp.h eval-plural.h os2compat.h libgnuintl.h loadinfo.h bindtextdom.c dcgettext.c dgettext.c gettext.c finddomain.c loadmsgcat.c localealias.c textdomain.c l10nflist.c explodename.c dcigettext.c dcngettext.c dngettext.c ngettext.c plural.y plural-exp.c localcharset.c localename.c osdep.c os2compat.c intl-compat.c"; \ for file in $dists; do \ /bin/install -c -m 644 ./$file \ /usr/local/share/gettext/intl/$file; \ done; \ chmod a+x /usr/local/share/gettext/intl/config.charset; \ dists="plural.c"; \ for file in $dists; do \ if test -f $file; then dir=.; else dir=.; fi; \ /bin/install -c -m 644 $dir/$file \ /usr/local/share/gettext/intl/$file; \ done; \ dists="xopen-msg.sed linux-msg.sed po2tbl.sed.in cat-compat.c COPYING.LIB-2 gettext.h libgettext.h plural-eval.c"; \ for file in $dists; do \ rm -f /usr/local/share/gettext/intl/$file; \ done; \ else \ : ; \ fi make[1]: Leaving directory `/root/hello-2.1.1/intl' Making install in po make[1]: Entering directory `/root/hello-2.1.1/po' /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share mkdir -p -- /usr/local/share/locale/ca/LC_MESSAGES installing ca.gmo as /usr/local/share/locale/ca/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/da/LC_MESSAGES installing da.gmo as /usr/local/share/locale/da/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/de/LC_MESSAGES installing de.gmo as /usr/local/share/locale/de/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/de_DE/LC_MESSAGES installing de_DE.gmo as /usr/local/share/locale/de_DE/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/el/LC_MESSAGES installing el.gmo as /usr/local/share/locale/el/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/eo/LC_MESSAGES installing eo.gmo as /usr/local/share/locale/eo/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/es/LC_MESSAGES installing es.gmo as /usr/local/share/locale/es/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/et/LC_MESSAGES installing et.gmo as /usr/local/share/locale/et/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/fi/LC_MESSAGES installing fi.gmo as /usr/local/share/locale/fi/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/fr/LC_MESSAGES installing fr.gmo as /usr/local/share/locale/fr/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/gl/LC_MESSAGES installing gl.gmo as /usr/local/share/locale/gl/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/he/LC_MESSAGES installing he.gmo as /usr/local/share/locale/he/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/hr/LC_MESSAGES installing hr.gmo as /usr/local/share/locale/hr/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/hu/LC_MESSAGES installing hu.gmo as /usr/local/share/locale/hu/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/id/LC_MESSAGES installing id.gmo as /usr/local/share/locale/id/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/it/LC_MESSAGES installing it.gmo as /usr/local/share/locale/it/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/ja/LC_MESSAGES installing ja.gmo as /usr/local/share/locale/ja/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/ko/LC_MESSAGES installing ko.gmo as /usr/local/share/locale/ko/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/lv/LC_MESSAGES installing lv.gmo as /usr/local/share/locale/lv/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/nb/LC_MESSAGES installing nb.gmo as /usr/local/share/locale/nb/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/nl/LC_MESSAGES installing nl.gmo as /usr/local/share/locale/nl/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/nn/LC_MESSAGES installing nn.gmo as /usr/local/share/locale/nn/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/pl/LC_MESSAGES installing pl.gmo as /usr/local/share/locale/pl/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/pt/LC_MESSAGES installing pt.gmo as /usr/local/share/locale/pt/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/pt_BR/LC_MESSAGES installing pt_BR.gmo as /usr/local/share/locale/pt_BR/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/ru/LC_MESSAGES installing ru.gmo as /usr/local/share/locale/ru/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/sk/LC_MESSAGES installing sk.gmo as /usr/local/share/locale/sk/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/sl/LC_MESSAGES installing sl.gmo as /usr/local/share/locale/sl/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/sv/LC_MESSAGES installing sv.gmo as /usr/local/share/locale/sv/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/tr/LC_MESSAGES installing tr.gmo as /usr/local/share/locale/tr/LC_MESSAGES/hello.mo mkdir -p -- /usr/local/share/locale/uk/LC_MESSAGES installing uk.gmo as /usr/local/share/locale/uk/LC_MESSAGES/hello.mo if test "hello" = "gettext"; then \ /bin/sh `case "./mkinstalldirs" in /*) echo "./mkinstalldirs" ;; *) echo ".././mkinstalldirs" ;; esac` /usr/local/share/gettext/po; \ for file in Makefile.in.in Makevars remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot ; do \ /bin/install -c -m 644 ./$file \ /usr/local/share/gettext/po/$file; \ done; \ else \ : ; \ fi make[1]: Leaving directory `/root/hello-2.1.1/po' Making install in src make[1]: Entering directory `/root/hello-2.1.1/src' make[2]: Entering directory `/root/hello-2.1.1/src' /bin/sh ../mkinstalldirs /usr/local/bin /bin/install -c hello /usr/local/bin/hello make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/root/hello-2.1.1/src' make[1]: Leaving directory `/root/hello-2.1.1/src' Making install in man make[1]: Entering directory `/root/hello-2.1.1/man' make[2]: Entering directory `/root/hello-2.1.1/man' make[2]: Nothing to be done for `install-exec-am'. /bin/sh ../mkinstalldirs /usr/local/man/man1 mkdir -p -- /usr/local/man/man1 /bin/install -c -m 644 ./hello.1 /usr/local/man/man1/hello.1 make[2]: Leaving directory `/root/hello-2.1.1/man' make[1]: Leaving directory `/root/hello-2.1.1/man' Making install in m4 make[1]: Entering directory `/root/hello-2.1.1/m4' make[2]: Entering directory `/root/hello-2.1.1/m4' make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/root/hello-2.1.1/m4' make[1]: Leaving directory `/root/hello-2.1.1/m4' Making install in tests make[1]: Entering directory `/root/hello-2.1.1/tests' make[2]: Entering directory `/root/hello-2.1.1/tests' make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/root/hello-2.1.1/tests' make[1]: Leaving directory `/root/hello-2.1.1/tests' make[1]: Entering directory `/root/hello-2.1.1' make[2]: Entering directory `/root/hello-2.1.1' make[2]: Nothing to be done for `install-exec-am'. make[2]: Nothing to be done for `install-data-am'. make[2]: Leaving directory `/root/hello-2.1.1' make[1]: Leaving directory `/root/hello-2.1.1'
Il convient maintenant de tester le nouveau logiciel :
[root@centos7 hello-2.1.1]# hello Hello, world!
Le logiciel hello a été correctement installé.
La commande rpm
A faire - Placez-vous dans le répertoire personnel de root grâce à la commande cd ~.
Afin de faciliter l'installation, la désinstallation et la gestion des logiciels (appelés paquets), CentOS et Red Hat utilisent un format de fichier de logiciels installables spécifique. Celui-ci s'appelle RPM pour Red Hat Package Manager. La commande utilisée pour manipuler ses paquets s'appelle aussi rpm.
Les options de la commande rpm sont :
[root@centos7 hello-2.1.1]# cd ~ [root@centos7 ~]# rpm --help Usage: rpm [OPTION...] Query/Verify package selection options: -a, --all query/verify all packages -f, --file query/verify package(s) owning file -g, --group query/verify package(s) in group -p, --package query/verify a package file --pkgid query/verify package(s) with package identifier --hdrid query/verify package(s) with header identifier --triggeredby query the package(s) triggered by the package --whatrequires query/verify the package(s) which require a dependency --whatprovides query/verify the package(s) which provide a dependency --nomanifest do not process non-package files as manifests Query options (with -q or --query): -c, --configfiles list all configuration files -d, --docfiles list all documentation files -L, --licensefiles list all license files --dump dump basic file information -l, --list list files in package --queryformat=QUERYFORMAT use the following query format -s, --state display the states of the listed files Verify options (with -V or --verify): --nofiledigest don't verify digest of files --nofiles don't verify files in package --nodeps don't verify package dependencies --noscript don't execute verify script(s) Install/Upgrade/Erase options: --allfiles install all files, even configurations which might otherwise be skipped --allmatches remove all packages which match <package> (normally an error is generated if <package> specified multiple packages) --badreloc relocate files in non-relocatable package -e, --erase=<package>+ erase (uninstall) package --excludedocs do not install documentation --excludepath=<path> skip files with leading component <path> --force short hand for --replacepkgs --replacefiles -F, --freshen=<packagefile>+ upgrade package(s) if already installed -h, --hash print hash marks as package installs (good with -v) --ignorearch don't verify package architecture --ignoreos don't verify package operating system --ignoresize don't check disk space before installing -i, --install install package(s) --justdb update the database, but do not modify the filesystem --nodeps do not verify package dependencies --nofiledigest don't verify digest of files --nocontexts don't install file security contexts --noorder do not reorder package installation to satisfy dependencies --noscripts do not execute package scriptlet(s) --notriggers do not execute any scriptlet(s) triggered by this package --nocollections do not perform any collection actions --oldpackage upgrade to an old version of the package (--force on upgrades does this automatically) --percent print percentages as package installs --prefix=<dir> relocate the package to <dir>, if relocatable --relocate=<old>=<new> relocate files from path <old> to <new> --replacefiles ignore file conflicts between packages --replacepkgs reinstall if the package is already present --test don't install, but tell if it would work or not -U, --upgrade=<packagefile>+ upgrade package(s) Common options for all rpm modes and executables: -D, --define='MACRO EXPR' define MACRO with value EXPR --undefine=MACRO undefine MACRO -E, --eval='EXPR' print macro expansion of EXPR --macros=<FILE:...> read <FILE:...> instead of default file(s) --nodigest don't verify package digest(s) --nosignature don't verify package signature(s) --rcfile=<FILE:...> read <FILE:...> instead of default file(s) -r, --root=ROOT use ROOT as top level directory (default: "/") --dbpath=DIRECTORY use database in DIRECTORY --querytags display known query tags --showrc display final rpmrc and macro configuration --quiet provide less detailed output -v, --verbose provide more detailed output --version print the version of rpm being used Options implemented via popt alias/exec: --scripts list install/erase scriptlets from package(s) --setperms set permissions of files in a package --setugids set user/group ownership of files in a package --conflicts list capabilities this package conflicts with --obsoletes list other packages removed by installing this package --provides list capabilities that this package provides --requires list capabilities required by package(s) --info list descriptive information from package(s) --changelog list change logs for this package --xml list metadata in xml --triggers list trigger scriptlets from package(s) --last list package(s) by install time, most recent first --dupes list duplicated packages --filesbypkg list all files from each package --fileclass list file names with classes --filecolor list file names with colors --fscontext list file names with security context from file system --fileprovide list file names with provides --filerequire list file names with requires --filecaps list file names with POSIX1.e capabilities Help options: -?, --help Show this help message --usage Display brief usage message
Configuration
Le fichier de configuration principal de la commande rpm est /usr/lib/rpm/rpmrc :
[root@centos7 ~]# more /usr/lib/rpm/rpmrc #/*! \page config_rpmrc Default configuration: /usr/lib/rpm/rpmrc # \verbatim # # This is a global RPM configuration file. All changes made here will # be lost when the rpm package is upgraded. Any per-system configuration # should be added to /etc/rpmrc, while per-user configuration should # be added to ~/.rpmrc. # ############################################################# # Values for RPM_OPT_FLAGS for various platforms # "fat" binary with both archs, for Darwin optflags: fat -O2 -g -arch i386 -arch ppc optflags: i386 -O2 -g -march=i386 -mtune=i686 optflags: i486 -O2 -g -march=i486 optflags: i586 -O2 -g -march=i586 optflags: i686 -O2 -g -march=i686 optflags: pentium3 -O2 -g -march=pentium3 optflags: pentium4 -O2 -g -march=pentium4 optflags: athlon -O2 -g -march=athlon optflags: geode -Os -g -m32 -march=geode optflags: ia64 -O2 -g --More--(5%)
Ces directives indiquent comment optimiser la construction d'un rpm en fonction du type de processeur retourné par la commande uname -p. Par exemple, la directive buildarchtranslate: athlon: i386 indique que le processus doit utiliser les optimisations i386 lors de la construction d'un src.rpm sur une architecture athlon. Si au contraire il est souhaité que les optimisations athlon soient utilisées, il convient d'inclure la ligne buildarchtranslate: athlon: athlon dans le fichier /etc/rpmrc. En effet lors de la mise à jour du paquet rpm, le fichier /usr/lib/rpm/rpmrc est écrasé. Toute modification des directives de ce fichier doivent être inscrites dans /etc/rpmrc ou dans un fichier ~/.rpmrc spécifique à un utilisateur.
LAB #2 - Utilisation
Afin de connaître la liste des paquets installés sur la machine, il convient de saisir la commande suivante dans une console en tant que root :
[root@centos7 ~]# rpm -qa | more gjs-1.36.1-2.el7.x86_64 mesa-libxatracker-9.2.5-5.20131218.el7.x86_64 gvfs-mtp-1.16.4-7.el7.x86_64 policycoreutils-2.2.5-11.el7.x86_64 setup-2.8.71-4.el7.noarch libXmu-1.1.1-5.1.el7.x86_64 gettext-libs-0.18.2.1-4.el7.x86_64 mousetweaks-3.8.0-3.el7.x86_64 libquvi-0.4.1-5.el7.x86_64 langtable-0.0.13-4.el7.noarch jline-1.0-8.el7.noarch perl-Encode-2.51-7.el7.x86_64 gnome-system-log-3.8.1-5.el7.x86_64 libreport-plugin-ureport-2.1.11-10.el7.centos.x86_64 basesystem-10.0-7.el7.centos.noarch festvox-slt-arctic-hts-0.20061229-28.el7.noarch perl-threads-shared-1.43-6.el7.x86_64 firefox-24.5.0-1.el7.centos.x86_64 sbc-1.0-5.el7.x86_64 tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch poppler-utils-0.22.5-6.el7.x86_64 perl-Pod-Simple-3.28-4.el7.noarch systemtap-runtime-2.4-14.el7.x86_64 --More--
Afin de connaître le nombre total de paquets installés sur la machine, utilisez la commande suivante :
[root@centos7 ~]# rpm -qa | wc -l 1194
Imaginons maintenant que vous souhaitez vérifier si un paquet contenant la chaine de caractères setup soit déjà installé sur la machine. Dans ce cas, il convient d'utiliser une commande telle la suivante :
[root@centos7 ~]# rpm -qa | grep setup setup-2.8.71-4.el7.noarch cryptsetup-libs-1.6.3-2.el7.x86_64 cryptsetup-python-1.6.3-2.el7.x86_64 ibus-setup-1.5.3-11.el7.noarch gnome-initial-setup-0.13.1-4.el7.x86_64 cryptsetup-1.6.3-2.el7.x86_64 initial-setup-0.3.9.12-1.el7.x86_64 setuptool-1.19.11-8.el7.x86_64 python-setuptools-0.9.8-3.el7.noarch
Afin de connaître les détails du paquet setup-2.8.71-4.el7.noarch, il convient de saisir la commande suivante :
[root@centos7 ~]# rpm -qi setup Name : setup Version : 2.8.71 Release : 4.el7 Architecture: noarch Install Date: Sun 08 Mar 2015 01:41:33 PM CET Group : System Environment/Base Size : 696310 License : Public Domain Signature : RSA/SHA256, Fri 04 Jul 2014 06:59:13 AM CEST, Key ID 24c6a8a7f4a80eb5 Source RPM : setup-2.8.71-4.el7.src.rpm Build Date : Tue 10 Jun 2014 04:04:36 AM CEST Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : https://fedorahosted.org/setup/ Summary : A set of system configuration and setup files Description : The setup package contains a set of important system configuration and setup files, such as passwd, group, and profile.
Afin de lister tous les fichiers installés par le paquet concerné, utilisez la commande suivante :
[root@centos7 ~]# rpm -ql setup /etc/aliases /etc/bashrc /etc/csh.cshrc /etc/csh.login /etc/environment /etc/exports /etc/filesystems /etc/fstab /etc/group /etc/gshadow /etc/host.conf /etc/hosts /etc/hosts.allow /etc/hosts.deny /etc/inputrc /etc/motd /etc/passwd /etc/printcap /etc/profile /etc/profile.d /etc/protocols /etc/securetty /etc/services /etc/shadow /etc/shells /usr/share/doc/setup-2.8.71 /usr/share/doc/setup-2.8.71/COPYING /usr/share/doc/setup-2.8.71/uidgid /var/log/lastlog
A l'inverse, si vous connaissez le nom d'un fichier et vous souhaitez savoir quel paquet l'a installé, utilisez la commande suivante :
[root@centos7 ~]# rpm -qf /etc/exports setup-2.8.71-4.el7.noarch
Pour connaître les fichiers modifiés depuis l'installation d'un paquet, utilisez la commande suivante :
# rpm -qV setup [Entrée]
Dans le cas où aucun fichier n'a été modifié, la console n'affiche rien. Dans le cas où les fichiers ont été modifiés, le système vous indique, fichier par fichier, les modifications apportées selon le tableau ci-dessous. Pour plus d'informations utilisez les commandes man et info :
Lettre ou mot Clé | Description |
---|---|
5 | Contrôle MD5 |
S | Taille du fichier |
L | Lien symbolique |
T | Date de modification |
D | Périphérique |
U | Utilisateur propriétaire |
G | Groupe propriétaire |
M | Droits d'accès |
? | Fichier illisible |
Manquant | Fichier manquant |
Important : Un paquet rpm est un fichier cpio modifié. Pour pouvoir extraire le contenu d'un src.rpm et explorer l'arborescence utilisé pour construire le paquet, utilisez la commande rpm2cpio paquet.src.rpm | cpio -i –make-directories
La commande yum
Yellow dog Updater, Modified (Yum) est le nom d'un programme utilitaire de gestion de paquets pour le système d'exploitation Linux, créé par Yellow Dog Linux et utilisé par CentOS, Redhat et Fedora. Il est à noter qu'il existe plusieurs interfaces graphiques pour yum, notamment yumex et kyum
Il permet de gérer l'installation et la mise à jour des logiciels installés. C'est une surcouche à RPM gérant les téléchargements et les dépendances, de la même manière que APT pour Debian, urpmi pour Mandriva et zypper pour SLES/openSUSE.
La commande yum prend la forme suivante :
# yum <options> <commande> <paquet(s)> [Entrée]
Les options et commandes de yum sont :
[root@centos7 ~]# yum --help Loaded plugins: fastestmirror, langpacks Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data deplist List a package's dependencies distribution-synchronization Synchronize installed packages to the latest available versions downgrade downgrade a package erase Remove a package or packages from your system fs Creates filesystem snapshots, or lists/deletes current snapshots. fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots. groups Display, or use, the groups information help Display a helpful usage message history Display, or use, the transaction history info Display details about a package or group of packages install Install a package or packages on your system langavailable Check available languages langinfo List languages information langinstall Install appropriate language packs for a language langlist List installed languages langremove Remove installed language packs for a language list List a package or groups of packages load-transaction load a saved transaction from filename makecache Generate the metadata cache provides Find what package provides the given value reinstall reinstall a package repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them repolist Display the configured software repositories search Search package details for the given string shell Run an interactive yum shell swap Simple way to swap packages, instead of using shell update Update a package or packages on your system update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system updateinfo Acts on repository update information upgrade Update packages taking obsoletes into account version Display a version for the machine and/or available repos. Options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C, --cacheonly run entirely from system cache, don't update cache -c [config file], --config=[config file] config file location -R [minutes], --randomwait=[minutes] maximum command wait time -d [debug level], --debuglevel=[debug level] debugging output level --showduplicates show duplicates, in repos, in list/search commands -e [error level], --errorlevel=[error level] error output level --rpmverbosity=[debug level name] debugging output level for rpm -q, --quiet quiet operation -v, --verbose verbose operation -y, --assumeyes answer yes for all questions --assumeno answer no for all questions --version show Yum version and exit --installroot=[path] set install root --enablerepo=[repo] enable one or more repositories (wildcards allowed) --disablerepo=[repo] disable one or more repositories (wildcards allowed) -x [package], --exclude=[package] exclude package(s) by name or glob --disableexcludes=[repo] disable exclude from main, for a repo or for everything --disableincludes=[repo] disable includepkgs for a repo or for everything --obsoletes enable obsoletes processing during updates --noplugins disable Yum plugins --nogpgcheck disable gpg signature checking --disableplugin=[plugin] disable plugins by name --enableplugin=[plugin] enable plugins by name --skip-broken skip packages with depsolving problems --color=COLOR control whether color is used --releasever=RELEASEVER set value of $releasever in yum config and repo files --downloadonly don't update, just download --downloaddir=DLDIR specifies an alternate directory to store packages --setopt=SETOPTS set arbitrary config and repo options --bugfix Include bugfix relevant packages, in updates --security Include security relevant packages, in updates --advisory=ADVS, --advisories=ADVS Include packages needed to fix the given advisory, in updates --bzs=BZS Include packages needed to fix the given BZ, in updates --cves=CVES Include packages needed to fix the given CVE, in updates --sec-severity=SEVS, --secseverity=SEVS Include security relevant packages matching the severity, in updates Plugin Options:
Configuration
La configuration principale de yum est effectuée en éditant le fichier /etc/yum.conf :
[root@centos7 ~]# cat /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release # This is the default, if you make this bigger yum won't see if the metadata # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. # It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d # exclude=httpd php mysql
Dépôts
Important : Un dépôt est un lieu de stockage de paquets binaires prêts à installer. Un dépôt peut être le DVD d'installation de la distribution, un dossier sur disque dur ou bien des serveurs distants accessibles par Internet.
Les dépôts de paquets sont spécifiés soit dans le fichier /etc/yum.conf, soit dans un fichier par dépôt stocké dans le répertoire /etc/yum.repos.d :
[root@centos7 ~]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo CentOS-Vault.repo
Par exemple :
[root@centos7 ~]# cat /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Utilisation
Les options les plus utilisées de yum sont :
Option | Description |
---|---|
-y | Réponse automatique de oui à toute question posée par yum. |
-t | Rend yum tolérant de certaines erreurs. Par exemple si deux paquets sont installés en même temps, une erreur de l'installation du premier paquet ne va pas arrêter l'installation du deuxième. |
- -exclude=<nom paquet> | Exclue le paquet indiqué de la transaction en cours |
Les commandes les plus utilisées de yum sont :
Commande | Description |
---|---|
install | Installer un ou plusieurs paquets. |
update | Mettre à jour un ou plusieurs paquets. Sans nom(s) de paquet(s), tous les paquets sont mis à jour. |
check-update | Visualiser une liste de mise à jour disponibles pour les paquets installés. |
remove | Supprimer un paquet |
provides | Visualiser une liste de paquets qui fournissent le fichier ou caractéristique spécifié. |
search | Trouver un paquet qui a la chaîne recherchée dans sa description. |
list | Trouver un paquet qui a la chaîne recherchée dans son nom. |
localinstall | Installer un ou plusieurs paquets stockés localement sur disque. |
La Commande yumdownloader
La commande yumdownloader est utilisée pour télécharger un paquet à partir d'un dépôt sans l'installer.
Cette commande prend la forme :
# yumdownloader --destdir /chemin paquet
Options de la Commande
Les options de la commande sont :
[root@centos7 ~]# yumdownloader --help Loaded plugins: fastestmirror, langpacks Usage: "yumdownloader [options] package1 [package2] [package..] Options: Plugin Options: Yum Base Options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C, --cacheonly run entirely from system cache, don't update cache -c [config file], --config=[config file] config file location -R [minutes], --randomwait=[minutes] maximum command wait time -d [debug level], --debuglevel=[debug level] debugging output level --showduplicates show duplicates, in repos, in list/search commands -e [error level], --errorlevel=[error level] error output level --rpmverbosity=[debug level name] debugging output level for rpm -q, --quiet quiet operation -v, --verbose verbose operation -y, --assumeyes answer yes for all questions --assumeno answer no for all questions --version show Yum version and exit --installroot=[path] set install root --enablerepo=[repo] enable one or more repositories (wildcards allowed) --disablerepo=[repo] disable one or more repositories (wildcards allowed) -x [package], --exclude=[package] exclude package(s) by name or glob --disableexcludes=[repo] disable exclude from main, for a repo or for everything --disableincludes=[repo] disable includepkgs for a repo or for everything --obsoletes enable obsoletes processing during updates --noplugins disable Yum plugins --nogpgcheck disable gpg signature checking --disableplugin=[plugin] disable plugins by name --enableplugin=[plugin] enable plugins by name --skip-broken skip packages with depsolving problems --color=COLOR control whether color is used --releasever=RELEASEVER set value of $releasever in yum config and repo files --downloadonly don't update, just download --downloaddir=DLDIR specifies an alternate directory to store packages --setopt=SETOPTS set arbitrary config and repo options --bugfix Include bugfix relevant packages, in updates --security Include security relevant packages, in updates --advisory=ADVS, --advisories=ADVS Include packages needed to fix the given advisory, in updates --bzs=BZS Include packages needed to fix the given BZ, in updates --cves=CVES Include packages needed to fix the given CVE, in updates --sec-severity=SEVS, --secseverity=SEVS Include security relevant packages matching the severity, in updates yumdownloader options: --destdir=DESTDIR destination directory (defaults to current directory) --urls just list the urls it would download instead of downloading --resolve resolve dependencies and download required packages --source operate on source packages --archlist=ARCHLIST only download packages of certain architecture(s)
LAB #3 - Utiliser la commande yum
Commencer par installer le paquet mc :
[root@centos7 ~]# yum install mc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr Resolving Dependencies --> Running transaction check ---> Package mc.x86_64 1:4.8.7-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mc x86_64 1:4.8.7-8.el7 base 1.7 M Transaction Summary ================================================================================ Install 1 Package Total download size: 1.7 M Installed size: 5.6 M Is this ok [y/d/N]: y Downloading packages: mc-4.8.7-8.el7.x86_64.rpm | 1.7 MB 00:15 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:mc-4.8.7-8.el7.x86_64 1/1 Verifying : 1:mc-4.8.7-8.el7.x86_64 1/1 Installed: mc.x86_64 1:4.8.7-8.el7 Complete!
Important : mc est un gestionnaire de fichiers utile en mode ligne de commande. Tapez la commande mc et expérimentez avec l'interface.
Supprimez maintenant le paquet mc :
[root@centos7 ~]# yum remove mc Loaded plugins: fastestmirror, langpacks Resolving Dependencies --> Running transaction check ---> Package mc.x86_64 1:4.8.7-8.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: mc x86_64 1:4.8.7-8.el7 @base 5.6 M Transaction Summary ================================================================================ Remove 1 Package Installed size: 5.6 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : 1:mc-4.8.7-8.el7.x86_64 1/1 Verifying : 1:mc-4.8.7-8.el7.x86_64 1/1 Removed: mc.x86_64 1:4.8.7-8.el7 Complete!
Recherchez le paquet mc :
[root@centos7 ~]# yum list mc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr Available Packages mc.x86_64 1:4.8.7-8.el7 base
Recherchez tout paquet commençant par kerne :
[root@centos7 ~]# yum list kerne\* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr Installed Packages kernel.x86_64 3.10.0-123.el7 @anaconda kernel-devel.x86_64 3.10.0-229.14.1.el7 @updates kernel-headers.x86_64 3.10.0-229.14.1.el7 @updates kernel-tools.x86_64 3.10.0-123.el7 @anaconda kernel-tools-libs.x86_64 3.10.0-123.el7 @anaconda Available Packages kernel.x86_64 3.10.0-229.14.1.el7 updates kernel-abi-whitelists.noarch 3.10.0-229.14.1.el7 updates kernel-debug.x86_64 3.10.0-229.14.1.el7 updates kernel-debug-devel.x86_64 3.10.0-229.14.1.el7 updates kernel-doc.noarch 3.10.0-229.14.1.el7 updates kernel-tools.x86_64 3.10.0-229.14.1.el7 updates kernel-tools-libs.x86_64 3.10.0-229.14.1.el7 updates kernel-tools-libs-devel.x86_64 3.10.0-229.14.1.el7 updates
Recherchez la chaîne mc :
[root@centos7 ~]# yum search mc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr =============================== N/S matched: mc ================================ abrt-addon-vmcore.x86_64 : abrt's vmcore addon bmc-snmp-proxy.noarch : Reconfigure SNMP to include host SNMP agent within BMC exchange-bmc-os-info.noarch : Let OS and BMC exchange info freeipmi-bmc-watchdog.x86_64 : IPMI BMC watchdog hamcrest-demo.noarch : Demos for hamcrest hamcrest-javadoc.noarch : Javadoc for hamcrest libXdmcp-devel.i686 : Development files for libXdmcp libXdmcp-devel.x86_64 : Development files for libXdmcp libXvMC.i686 : X.Org X11 libXvMC runtime library libXvMC.x86_64 : X.Org X11 libXvMC runtime library libXvMC-devel.i686 : X.Org X11 libXvMC development package libXvMC-devel.x86_64 : X.Org X11 libXvMC development package libmemcached.i686 : Client library and command line tools for memcached server libmemcached.x86_64 : Client library and command line tools for memcached server libmemcached-devel.i686 : Header files and development libraries for : libmemcached libmemcached-devel.x86_64 : Header files and development libraries for : libmemcached memcached-devel.i686 : Files needed for development using memcached protocol memcached-devel.x86_64 : Files needed for development using memcached protocol php-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon python-memcached.noarch : A Python memcached client library smc-fonts-common.noarch : Common files for smc-fonts tomcat-admin-webapps.noarch : The host-manager and manager web applications for : Apache Tomcat tomcat-docs-webapp.noarch : The docs web application for Apache Tomcat tomcat-javadoc.noarch : Javadoc generated documentation for Apache Tomcat tomcat-jsp-2.2-api.noarch : Apache Tomcat JSP API implementation classes tomcat-jsvc.noarch : Apache jsvc wrapper for Apache Tomcat as separate service tomcat-lib.noarch : Libraries needed to run the Tomcat Web container tomcat-servlet-3.0-api.noarch : Apache Tomcat Servlet API implementation classes tomcat-webapps.noarch : The ROOT and examples web applications for Apache Tomcat tomcatjss.noarch : JSSE implementation using JSS for Tomcat crash.x86_64 : Kernel analysis utility for live systems, netdump, diskdump, : kdump, LKCD or mcore dumpfiles crash-devel.i686 : kernel crash analysis utility for live systems, netdump, : diskdump, kdump, LKCD or mcore dumpfiles crash-devel.x86_64 : kernel crash analysis utility for live systems, netdump, : diskdump, kdump, LKCD or mcore dumpfiles fence-virtd-serial.x86_64 : Serial VMChannel listener for fence-virtd hamcrest.noarch : Library of matchers for building test expressions libXdmcp.i686 : X Display Manager Control Protocol library libXdmcp.x86_64 : X Display Manager Control Protocol library mc.x86_64 : User-friendly text console file manager and visual shell mcelog.x86_64 : Tool to translate x86-64 CPU Machine Check Exception data mcstrans.x86_64 : SELinux Translation Daemon memcached.x86_64 : High Performance, Distributed Memory Object Cache pki-tps-tomcat.noarch : Certificate System - Token Processing Service sblim-wbemcli.x86_64 : SBLIM WBEM Command Line Interface smc-anjalioldlipi-fonts.noarch : Open Type Fonts for Malayalam script smc-dyuthi-fonts.noarch : Open Type Fonts for Malayalam script smc-kalyani-fonts.noarch : Open Type Fonts for Malayalam script smc-meera-fonts.noarch : Open Type Fonts for Malayalam script smc-rachana-fonts.noarch : Open Type Fonts for Malayalam script smc-raghumalayalam-fonts.noarch : Open Type Fonts for Malayalam script smc-suruma-fonts.noarch : Open Type Fonts for Malayalam script strongimcv.i686 : Trusted Network Connect (TNC) Architecture strongimcv.x86_64 : Trusted Network Connect (TNC) Architecture tncfhh-examples.i686 : Example IMC/IMV implementations tncfhh-examples.x86_64 : Example IMC/IMV implementations tomcat.noarch : Apache Servlet/JSP Engine, RI for Servlet 3.0/JSP 2.2 API tomcat-el-2.2-api.noarch : Expression Language v2.2 API xorg-x11-drv-openchrome-devel.i686 : Xorg X11 openchrome video driver XvMC : development package xorg-x11-drv-openchrome-devel.x86_64 : Xorg X11 openchrome video driver XvMC : development package Name and summary matches only, use "search all" for everything.
Recherchez quel paquet fournit mc :
[root@centos7 ~]# yum provides mc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr 1:mc-4.8.7-8.el7.x86_64 : User-friendly text console file manager and visual : shell Repo : base
Contrôlez maintenant les dépôts configurés dans votre système :
[root@centos7 ~]# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr repo id repo name status base/7/x86_64 CentOS-7 - Base 8,652 extras/7/x86_64 CentOS-7 - Extras 214 updates/7/x86_64 CentOS-7 - Updates 1,505 repolist: 10,371
Vérifiez la disponibilité de mises à jour :
[root@centos7 ~]# yum check-update Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr NetworkManager.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates NetworkManager-glib.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates NetworkManager-tui.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates abrt.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-ccpp.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-kerneloops.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-pstoreoops.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-python.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-vmcore.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-addon-xorg.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-cli.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-console-notification.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-dbus.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-desktop.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-gui.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-gui-libs.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-libs.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-python.x86_64 2.1.11-22.el7.centos.0.1 updates abrt-tui.x86_64 2.1.11-22.el7.centos.0.1 updates alsa-firmware.noarch 1.0.28-2.el7 base alsa-lib.x86_64 1.0.28-2.el7 base alsa-utils.x86_64 1.0.28-4.el7 base anaconda.x86_64 19.31.123-1.el7.centos.2 base anaconda-widgets.x86_64 19.31.123-1.el7.centos.2 base at.x86_64 3.1.13-17.el7_0.1 base audit.x86_64 2.4.1-5.el7 base audit-libs.x86_64 2.4.1-5.el7 base audit-libs-python.x86_64 2.4.1-5.el7 base ...
Appliquez les mises-à-jour :
[root@centos7 ~]# yum update Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr Resolving Dependencies ... Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: NetworkManager x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 1.9 M replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 NetworkManager-adsl x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 122 k replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 NetworkManager-bluetooth x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 141 k replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 NetworkManager-team x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 122 k replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 NetworkManager-wifi x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 151 k replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 NetworkManager-wwan x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 142 k replacing NetworkManager.x86_64 1:0.9.9.1-13.git20140326.4dba720.el7 kernel x86_64 3.10.0-229.14.1.el7 updates 31 M Updating: NetworkManager-glib x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 376 k NetworkManager-tui x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1 updates 203 k abrt x86_64 2.1.11-22.el7.centos.0.1 updates 511 k abrt-addon-ccpp x86_64 2.1.11-22.el7.centos.0.1 updates 183 k abrt-addon-kerneloops x86_64 2.1.11-22.el7.centos.0.1 updates 100 k abrt-addon-pstoreoops x86_64 2.1.11-22.el7.centos.0.1 updates 91 k abrt-addon-python x86_64 2.1.11-22.el7.centos.0.1 updates 97 k abrt-addon-vmcore x86_64 2.1.11-22.el7.centos.0.1 updates 101 k abrt-addon-xorg x86_64 2.1.11-22.el7.centos.0.1 updates 92 k abrt-cli x86_64 2.1.11-22.el7.centos.0.1 updates 82 k abrt-console-notification x86_64 2.1.11-22.el7.centos.0.1 updates 83 k abrt-dbus x86_64 2.1.11-22.el7.centos.0.1 updates 115 k ... python-dmidecode x86_64 3.10.13-11.el7 base 82 k python-ethtool x86_64 0.8-5.el7 base 33 k python-meh-gui noarch 0.25.2-1.el7 base 15 k python-six noarch 1.3.0-4.el7 base 18 k rdma noarch 7.1_3.17-5.el7 base 28 k tagsoup noarch 1.2.1-8.el7 base 112 k trousers x86_64 0.3.11.2-4.el7_1 updates 286 k Transaction Summary ====================================================================================================================================================== Install 7 Packages (+37 Dependent packages) Upgrade 462 Packages Total size: 510 M Is this ok [y/d/N]: y
A faire - Répondez y à la question Is this ok [y/d/N]: y. Pendant la mise à jour de votre système, consultez le manuel de yum pour vous renseigner sur les autres commandes et options.
Les Bibliothèques Partagées
Présentation
Introduction
Les bibliothèques partagées sont des fonctions communes à plusieurs programmes différents d'un même domaine (son, base de données, vidéo etc.). Les fonctions proposées par une ou plusieurs bibliothèques forment un API (Application Programming Interface). Sous Linux les bibliothèques se nomment Shared Objects et portent le suffixe .so.
Stockage
Les bibliothèques partagées sont stockées par convention dans des répertoires lib, par exemple :
Répertoire | Contenu |
---|---|
/lib | Bibliothèques du système de base |
/usr/lib | Bibliothèques utilisateurs |
/usr/local/lib | Bibliothèques locales |
/usr/X11R6/lib | Bibliothèques de l'environnement X |
/opt/kde4/lib | Bibliothèques de KDE |
Important : La bibliothèque la plus importante est libc. Sans elle, le système Linux ne peut pas fonctionner.
ld-linux.so.2
La bibliothèque ld-linux.so.2 est utilisée par le système pour créer un lien avec une bibliothèque partagée au moment de l'exécution d'un programme et s'appelle le chargeur de liens. Ce dernier recherche des bibliothèques partagées dans un ordre précis :
- dans les chemins précisés par la variable système LD_LIBRARY_PATH,
- dans les chemins précisés dans le contenu compilé du fichier /etc/ld.so.cache,
- dans /lib et /usr/lib.
Il est à noter que le contenu du cache ld.so.cache est construit à partir des informations contenus dans le fichier de configuration /etc/ld.so.conf.
Afin d'étudier les bibliothèques liées à une application, nous allons d'abord installer l'application mc :
[root@centos7 ~]# yum install mc Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: fr2.rpmfind.net * extras: mirror.ibcp.fr * updates: mirror.ibcp.fr Resolving Dependencies --> Running transaction check ---> Package mc.x86_64 1:4.8.7-8.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================================== Package Arch Version Repository Size ====================================================================================================================================================== Installing: mc x86_64 1:4.8.7-8.el7 base 1.7 M Transaction Summary ====================================================================================================================================================== Install 1 Package Total download size: 1.7 M Installed size: 5.6 M Is this ok [y/d/N]: y
La Commande ldd
Pour déterminer quelles sont les bibliothèques liées à une application, il convient d'utiliser la commande ldd :
[root@centos7 ~]# ldd /usr/bin/mc linux-vdso.so.1 => (0x00007fff0fdfe000) libslang.so.2 => /lib64/libslang.so.2 (0x00007f8896ae0000) libgpm.so.2 => /lib64/libgpm.so.2 (0x00007f88968d9000) libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f88966ae000) libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f88964aa000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f8896181000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8895f64000) libc.so.6 => /lib64/libc.so.6 (0x00007f8895ba3000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f889599f000) libm.so.6 => /lib64/libm.so.6 (0x00007f889569c000) libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f8895475000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f889524b000) libssl.so.10 => /lib64/libssl.so.10 (0x00007f8894fde000) libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f8894bf9000) libz.so.1 => /lib64/libz.so.1 (0x00007f88949e3000) /lib64/ld-linux-x86-64.so.2 (0x00007f8896e6b000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f8894798000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f88944b8000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f88942b4000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f889407e000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f8893e70000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f8893c6c000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f8893a51000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f889382c000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f88935ca000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f88933a5000)
Afin de comprendre ce qui se passe dans le cas où une bibliothèque est manquante, renommez la bibliothèque /usr/lib/libslang.so.2 en /usr/lib/libslang.so.2.old :
[root@centos7 ~]# mv /lib64/libslang.so.2 /lib64/libslang.so.2.old
Exécutez de nouveau la commande ldd. Vous obtiendrez un résultat similaire à celui-ci :
[root@centos7 ~]# ldd /usr/bin/mc linux-vdso.so.1 => (0x00007fffe31f9000) libslang.so.2 => not found libgpm.so.2 => /lib64/libgpm.so.2 (0x00007f7b54e49000) libssh2.so.1 => /lib64/libssh2.so.1 (0x00007f7b54c1f000) libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f7b54a1b000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f7b546f1000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7b544d5000) libc.so.6 => /lib64/libc.so.6 (0x00007f7b54114000) libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f7b53eec000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f7b53cc2000) libssl.so.10 => /lib64/libssl.so.10 (0x00007f7b53a56000) libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007f7b53670000) libz.so.1 => /lib64/libz.so.1 (0x00007f7b5345a000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f7b53256000) /lib64/ld-linux-x86-64.so.2 (0x00007f7b55064000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f7b5300b000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f7b52d2b000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f7b52b27000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f7b528f1000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f7b526e3000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f7b524df000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f7b522c4000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f7b5209f000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f7b51e3d000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f7b51c18000)
Notez la présence de la ligne libslang.so.2 ⇒ not found. Compte tenu de la bibliothèque partagée manquante, le programme mc ne peut plus être lancé :
[root@centos7 ~]# mc mc: error while loading shared libraries: libslang.so.2: cannot open shared object file: No such file or directory
Renommez la bibliothèque correctement et vérifiez la résolution de l'erreur précédente avec la commande ldd :
[root@centos7 ~]# mv /lib64/libslang.so.2.old /lib64/libslang.so.2 [root@centos7 ~]# ldd /usr/bin/mc linux-vdso.so.1 => (0x00007fff541fe000) libslang.so.2 => /lib64/libslang.so.2 (0x00007fcb40b0a000) libgpm.so.2 => /lib64/libgpm.so.2 (0x00007fcb40903000) libssh2.so.1 => /lib64/libssh2.so.1 (0x00007fcb406d8000) libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007fcb404d4000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fcb401ab000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcb3ff8e000) libc.so.6 => /lib64/libc.so.6 (0x00007fcb3fbcd000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fcb3f9c9000) libm.so.6 => /lib64/libm.so.6 (0x00007fcb3f6c6000) libncurses.so.5 => /lib64/libncurses.so.5 (0x00007fcb3f49f000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007fcb3f275000) libssl.so.10 => /lib64/libssl.so.10 (0x00007fcb3f008000) libcrypto.so.10 => /lib64/libcrypto.so.10 (0x00007fcb3ec23000) libz.so.1 => /lib64/libz.so.1 (0x00007fcb3ea0d000) /lib64/ld-linux-x86-64.so.2 (0x00007fcb40e95000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007fcb3e7c2000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007fcb3e4e2000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fcb3e2de000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007fcb3e0a8000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007fcb3de9a000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fcb3dc96000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fcb3da7b000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fcb3d856000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fcb3d5f4000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fcb3d3cf000)
Le fichier /etc/ld.so.conf
Le fichier /etc/ld.so.conf est utilisé pour configurer le cache /etc/ld.so.cache :
[root@centos7 ~]# cat /etc/ld.so.conf include ld.so.conf.d/*.conf
Dans ce cas, le fichier ne contient qu'une directive include qui renvoie vers le contenu du répertoire /etc/ld.so.conf.d/ :
[root@centos7 ~]# ls -l /etc/ld.so.conf.d/ total 20 -rw-r--r--. 1 root root 19 Jun 9 2014 dyninst-x86_64.conf -r--r--r--. 1 root root 63 Jun 30 2014 kernel-3.10.0-123.el7.x86_64.conf -rw-r--r--. 1 root root 17 Jun 10 2014 libiscsi-x86_64.conf -rw-r--r--. 1 root root 17 Jun 10 2014 mariadb-x86_64.conf -rw-r--r--. 1 root root 24 Jun 9 2014 tracker-x86_64.conf
Par exemple, le contenu du fichier mariadb-x86_64.conf est :
[root@centos7 ~]# cat /etc/ld.so.conf.d/mariadb-x86_64.conf /usr/lib64/mysql
La Commande ldconfig
La commande ldconfig est utilisée pour :
- mettre à jour le cache pour les chemins inclus dans le fichier /etc/ld.so.conf ainsi que pour les répertoires /lib et /usr/lib. L'option -N de la commande ldconfig empêche la mise à jour des chemins dans le fichier,
- mettre à jour les liens symboliques sur les bibliothèques. L'option -X de la commande ldconfig empêche la mise à jour des liens symboliques.
Les liens symboliques sont utilisés pour gérer les versions de bibliothèques.
La commande ldconfig peut être utilisée avec l'option -p pour visualiser le contenu du cache :
[root@centos7 ~]# ldconfig -p | more 889 libs found in cache `/etc/ld.so.cache' p11-kit-trust.so (libc6,x86-64) => /lib64/p11-kit-trust.so libzapojit-0.0.so.0 (libc6,x86-64) => /lib64/libzapojit-0.0.so.0 libz.so.1 (libc6,x86-64) => /lib64/libz.so.1 libyelp.so.0 (libc6,x86-64) => /lib64/libyelp.so.0 libyajl.so.2 (libc6,x86-64) => /lib64/libyajl.so.2 libxtables.so.10 (libc6,x86-64) => /lib64/libxtables.so.10 libxslt.so.1 (libc6,x86-64) => /lib64/libxslt.so.1 libxml2.so.2 (libc6,x86-64) => /lib64/libxml2.so.2 libxmlrpc_util.so.3 (libc6,x86-64) => /lib64/libxmlrpc_util.so.3 libxmlrpc_server_cgi.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server_cgi.so.3 libxmlrpc_server_abyss.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server_abyss.so.3 libxmlrpc_server.so.3 (libc6,x86-64) => /lib64/libxmlrpc_server.so.3 libxmlrpc_client.so.3 (libc6,x86-64) => /lib64/libxmlrpc_client.so.3 libxmlrpc_abyss.so.3 (libc6,x86-64) => /lib64/libxmlrpc_abyss.so.3 libxmlrpc.so.3 (libc6,x86-64) => /lib64/libxmlrpc.so.3 libxklavier.so.16 (libc6,x86-64) => /lib64/libxklavier.so.16 libxkbfile.so.1 (libc6,x86-64) => /lib64/libxkbfile.so.1 libxcb.so.1 (libc6,x86-64) => /lib64/libxcb.so.1 libxcb-xvmc.so.0 (libc6,x86-64) => /lib64/libxcb-xvmc.so.0 libxcb-xv.so.0 (libc6,x86-64) => /lib64/libxcb-xv.so.0 libxcb-xtest.so.0 (libc6,x86-64) => /lib64/libxcb-xtest.so.0 libxcb-xselinux.so.0 (libc6,x86-64) => /lib64/libxcb-xselinux.so.0 libxcb-xkb.so.0 (libc6,x86-64) => /lib64/libxcb-xkb.so.0 libxcb-xinerama.so.0 (libc6,x86-64) => /lib64/libxcb-xinerama.so.0 libxcb-xf86dri.so.0 (libc6,x86-64) => /lib64/libxcb-xf86dri.so.0 libxcb-xfixes.so.0 (libc6,x86-64) => /lib64/libxcb-xfixes.so.0 libxcb-xevie.so.0 (libc6,x86-64) => /lib64/libxcb-xevie.so.0 --More--
Pour ajouter des bibliothèques partagées, il convient de :
- créer un fichier dans le répertoire /etc/ld.so.conf.d/ et d'y inscrire le ou les chemins vers le lieu de stockage des bibliothèques partagées à ajouter,
- exécuter la commande ldconfig -v, où v implique verbose, afin de reconstruire le cache.
La Commande dpkg
A faire - Placez-vous dans le répertoire personnel de root grâce à la commande cd ~.
Afin de faciliter l'installation, la désinstallation et la gestion des logiciels (appelés paquets) sous Linux, Debian et ses dérivés utilisent un format de fichier de logiciels installables spécifique. Celui-ci s'appelle DEB. La commande utilisée pour manipuler ses paquetages s'appelle dpkg.
Les options de la commande dpkg sont :
root@debian9:~# dpkg --help Syntaxe : dpkg [<option> ...] <commande> Commands: -i|--install <.deb file name> ... | -R|--recursive <directory> ... --unpack <.deb file name> ... | -R|--recursive <directory> ... -A|--record-avail <.deb file name> ... | -R|--recursive <directory> ... --configure <package> ... | -a|--pending --triggers-only <package> ... | -a|--pending -r|--remove <package> ... | -a|--pending -P|--purge <package> ... | -a|--pending -V|--verify <package> ... Verify the integrity of package(s). --get-selections [<pattern> ...] Get list of selections to stdout. --set-selections Set package selections from stdin. --clear-selections Deselect every non-essential package. --update-avail [<Packages-file>] Replace available packages info. --merge-avail [<Packages-file>] Merge with info from file. --clear-avail Erase existing available info. --forget-old-unavail Forget uninstalled unavailable pkgs. -s|--status <package> ... Display package status details. -p|--print-avail <package> ... Display available version details. -L|--listfiles <package> ... List files 'owned' by package(s). -l|--list [<pattern> ...] List packages concisely. -S|--search <pattern> ... Find package(s) owning file(s). -C|--audit [<package> ...] Check for broken package(s). --yet-to-unpack Print packages selected for installation. --predep-package Print pre-dependencies to unpack. --add-architecture <arch> Add <arch> to the list of architectures. --remove-architecture <arch> Remove <arch> from the list of architectures. --print-architecture Print dpkg architecture. --print-foreign-architectures Print allowed foreign architectures. --assert-<feature> Assert support for the specified feature. --validate-<thing> <string> Validate a <thing>'s <string>. --compare-versions <a> <op> <b> Compare version numbers - see below. --force-help Show help on forcing. -Dh|--debug=help Show help on debugging. -?, --help Afficher ce message. --version Afficher la version. Fonctionnalités pouvant être déclarées : support-predepends, working-epoch, long-filenames, multi-conrep, multi-arch, versioned-provides. Validatable things: pkgname, archname, trigname, version. Utiliser dpkg avec -b, --build, -c, --contents, -e, --control, -I, --info, -f, --field, -x, --extract, -X, --vextract, --ctrl-tarfile, --fsys-tarfile sur les archives (taper dpkg-deb --help.) Options : --admindir=<rép.> Utilise le répertoire <rép.> au lieu de /var/lib/dpkg. --root=<rép.> Installe sur un système alternatif dont la racine est située à un autre endroit. --instdir=<rép.> Change la racine d'installation sans changer le répertoire d'administration. --path-exclude=<motif> Ne pas installer les chemins correspondant à un motif du shell. --path-include=<pattern> Réinclut un motif après une exclusion antérieure. -O|--selected-only Ignore les paquets non sélectionnées pour être installés ou mis à niveau. -E|--skip-same-version Ignore les paquets dont la version est la même que celle installée. -G|--refuse-downgrade Ignore les paquets dont la version est moins récente que celle installée. -B|--auto-deconfigure Installe même si cela entraîne la rupture d'autres paquets. --[no-]triggers Passe ou force les actions différées invoquées par le traitement. --verify-format=<format> Vérifie le format de sortie (pris en charge : « rpm »). --no-debsig N'essaie pas d'authentifier les signatures des paquets. --no-act|--dry-run|--simulate Se contente d'afficher les actions à effectuer sans les réaliser effectivement. -D|--debug=<octal> Active le débogage (voir -Dhelp ou --debug=help). --status-fd <n> Envoie les mises à jour d'état au descripteur de fichier <n>. --status-logger=<commande> Envoie les mises à jour d'état sur l'entrée standard de la commande <commande>. --log=<fichier> Enregistre dans <fichier> les changements d'état et les actions effectuées. --ignore-depends=<paquet>,... Ignore les dépendances impliquant <paquet>. --force-... Passe outre les problèmes (voir --force-help). --no-force-...|--refuse-... Arrête en cas de problème(s). --abort-after <n> Arrête après avoir rencontré <n> erreurs. Les opérateurs de comparaison pour --compare-versions sont les suivants : lt le eq ne ge gt (ne considérer aucune version comme plus tardive que n'importe quelle version) lt-nl le-nl ge-nl gt-nl (ne considérer aucune version comme plus récente que n'importe quelle version) < << <= = >= >> > (uniquement pour des raison de compatibilité avec la syntaxe du fichier control) Utilisez « apt » ou « aptitude » pour gérer les paquets de manière plus conviviale.
Configuration
Le fichier de configuration proncipal de la commande dpkg est /etc/dpkg/dpkg.cfg :
root@debian9:~# cat /etc/dpkg/dpkg.cfg # dpkg configuration file # # This file can contain default options for dpkg. All command-line # options are allowed. Values can be specified by putting them after # the option, separated by whitespace and/or an `=' sign. # # Do not enable debsig-verify by default; since the distribution is not using # embedded signatures, debsig-verify would reject all packages. no-debsig # Log status changes and actions to a file. log /var/log/dpkg.log
Les directives dans ce fichier sont les option de la commande dpkg sans les charactères –.
Il est important à noter que la base de données de la commande dpkg se trouve dans le répertoire /var/lib/dpkg :
root@debian9:~# ls -l /var/lib/dpkg total 2792 drwxr-xr-x 2 root root 4096 janv. 22 13:37 alternatives -rw-r--r-- 1 root root 124816 janv. 22 13:18 available -rw-r--r-- 1 root root 8 janv. 22 13:18 cmethopt -rw-r--r-- 1 root root 559 janv. 22 13:39 diversions -rw-r--r-- 1 root root 614 janv. 22 13:39 diversions-old drwxr-xr-x 2 root root 258048 mars 25 17:04 info -rw-r----- 1 root root 0 mars 25 17:04 lock drwxr-xr-x 2 root root 4096 juin 26 2018 parts -rw-r--r-- 1 root root 100 janv. 22 13:37 statoverride -rw-r--r-- 1 root root 35 janv. 22 13:18 statoverride-old -rw-r--r-- 1 root root 1215468 mars 25 17:04 status -rw-r--r-- 1 root root 1215540 mars 25 17:04 status-old drwxr-xr-x 2 root root 4096 janv. 22 13:37 triggers drwxr-xr-x 2 root root 4096 mars 25 17:04 updates
Important - Il est recommendé d'inclure ce répertoire et son contenu dans les sauvegardes régulières.
Utilisation
Afin de connaître la liste des paquets disponibles sur la machine, il convient de saisir la commande suivante dans une fenêtre de console en tant que root :
root@debian9:~# dpkg -l | more Souhait=inconnU/Installé/suppRimé/Purgé/H=à garder | État=Non/Installé/fichier-Config/dépaqUeté/échec-conFig/H=semi-installé/W=attend-traitement-déclenchements |/ Err?=(aucune)/besoin Réinstallation (État,Err: majuscule=mauvais) ||/ Nom Version Architecture Description +++-=====================================-=================================-============-=============================================================================== ii acl 2.2.52-3+b1 amd64 Access control list utilities ii adduser 3.115 all add and remove users and groups ii adwaita-icon-theme 3.22.0-1+deb9u1 all default icon theme of GNOME ii alsa-utils 1.1.3-1 amd64 Utilities for configuring and using ALSA ii anacron 2.3-24 amd64 cron-like program that doesn't go by time ii ant 1.9.9-1+deb9u1 all Java based build tool like make ii ant-optional 1.9.9-1+deb9u1 all Java based build tool like make - optional libraries ii apt 1.4.9 amd64 commandline package manager ii apt-listchanges 3.10 all package change history notification tool ii apt-utils 1.4.9 amd64 package management related utility programs ii aspell 0.60.7~20110707-3+b2 amd64 GNU Aspell spell-checker ii aspell-en 2016.11.20-0-0.1 all English dictionary for GNU Aspell ii aspell-fr 0.50-3-8 all French dictionary for aspell ii at-spi2-core 2.22.0-6+deb9u1 amd64 Assistive Technology Service Provider Interface (dbus core) ii avahi-autoipd 0.6.32-2 amd64 Avahi IPv4LL network address configuration daemon ii avahi-daemon 0.6.32-2 amd64 Avahi mDNS/DNS-SD daemon ii base-files 9.9+deb9u6 amd64 Debian base system miscellaneous files ii base-passwd 3.5.43 amd64 Debian base system master password and group files ii bash 4.4-5 amd64 GNU Bourne Again SHell ii bash-completion 1:2.1-4.3 all programmable completion for the bash shell ii bind9-host 1:9.10.3.dfsg.P4-12.3+deb9u4 amd64 Version of 'host' bundled with BIND 9.X ii bluetooth 5.43-2+deb9u1 all Bluetooth support ii bluez 5.43-2+deb9u1 amd64 Bluetooth tools and daemons ii bsdmainutils 9.0.12+nmu1 amd64 collection of more utilities from FreeBSD ii bsdutils 1:2.29.2-1+deb9u1 amd64 basic utilities from 4.4BSD-Lite ii busybox 1:1.22.0-19+b3 amd64 Tiny utilities for small and embedded systems ii bzip2 1.0.6-8.1 amd64 high-quality block-sorting file compressor - utilities ii ca-certificates 20161130+nmu1+deb9u1 all Common CA certificates ii ca-certificates-java 20170531+nmu1 all Common CA certificates (JKS keystore) ii coinor-libcbc3 2.8.12-1+b2 amd64 Coin-or branch-and-cut mixed integer programming solver (shared libraries) ii coinor-libcgl1 0.58.9-1+b1 amd64 COIN-OR Cut Generation Library ii coinor-libclp1 1.15.10-3+b1 amd64 Coin-or linear programming solver (shared libraries) ii coinor-libcoinmp1v5:amd64 1.7.6+dfsg1-2 amd64 Simple C API for COIN-OR Solvers Clp and Cbc -- library ii coinor-libcoinutils3v5 2.9.15-4 amd64 Coin-or collection of utility classes (binaries and libraries) --Plus--
Important - L'option -l liste les paquets disponibles spécifiés par le fichier /var/lib/dpkg/available.
root@debian9:~# more /var/lib/dpkg/available Package: gcc-6-base Source: gcc-6 Version: 6.3.0-18+deb9u1 Installed-Size: 209 Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org> Architecture: amd64 Breaks: gcc-4.4-base (<< 4.4.7), gcc-4.7-base (<< 4.7.3), gcj-4.4-base (<< 4.4.6-9~), gcj-4.6-base (<< 4.6.1-4~), gnat-4.4-base (<< 4.4.6-3~), gnat-4.6 (<< 4.6.1-5~) Description: GCC, the GNU Compiler Collection (base package) Description-md5: b6e93638a6d08ea7a18929d7cf078e5d Multi-Arch: same Homepage: http://gcc.gnu.org/ Tag: role::shared-lib Section: libs Priority: required Filename: pool/main/g/gcc-6/gcc-6-base_6.3.0-18+deb9u1_amd64.deb Size: 179954 MD5sum: fae6ab4e4c63ceb1b18df23f13dc7776 SHA256: 56a205b9032e54edffeab48b0e76ffc829e20e6c7c3c5976cf5e278f0471705f Package: libgcc1 Source: gcc-6 (6.3.0-18+deb9u1) Version: 1:6.3.0-18+deb9u1 Installed-Size: 108 Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org> Architecture: amd64 Depends: gcc-6-base (= 6.3.0-18+deb9u1), libc6 (>= 2.14) Breaks: gcc-4.3 (<< 4.3.6-1), gcc-4.4 (<< 4.4.6-4), gcc-4.5 (<< 4.5.3-2) Description: GCC support library Description-md5: bbd60d723e97d8e06c04228ee4c76f10 Multi-Arch: same Homepage: http://gcc.gnu.org/ Tag: role::shared-lib Section: libs Priority: required Filename: pool/main/g/gcc-6/libgcc1_6.3.0-18+deb9u1_amd64.deb Size: 38018 MD5sum: 486770bbab9926da4c945733d372966a SHA256: 423a6541ee7ade69967c99492e267e724fd4675de53310861af5d1a1d249c4bf --Plus--(1%)
Le statut de chaque paquet est inclus dans le fichier /var/lib/dpkg/status :
root@debian9:~# more /var/lib/dpkg/status Package: libatk-adaptor Status: install ok installed Priority: optional Section: misc Installed-Size: 46 Maintainer: Debian Accessibility Team <debian-accessibility@lists.debian.org> Architecture: amd64 Multi-Arch: same Source: at-spi2-atk Version: 2.22.0-2 Replaces: at-spi Provides: at-spi Depends: libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.15.4), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.2.5), libdbus-1-3 (>= 1.9.14), libglib2.0-0 (>= 2.12.0) Conflicts: at-spi Conffiles: /etc/X11/Xsession.d/90atk-adaptor 4078a3f4ac00fc84e750302cad860730 Description: AT-SPI 2 toolkit bridge This package includes a gtk-module that bridges ATK to the new D-Bus based AT-SPI. Homepage: https://wiki.gnome.org/Accessibility Package: libquadmath0 Status: install ok installed Priority: optional Section: libs Installed-Size: 265 Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org> Architecture: amd64 Multi-Arch: same Source: gcc-6 Version: 6.3.0-18+deb9u1 Depends: gcc-6-base (= 6.3.0-18+deb9u1), libc6 (>= 2.23) Description: GCC Quad-Precision Math Library A library, which provides quad-precision mathematical functions on targets supporting the __float128 datatype. The library is used to provide on such targets the REAL(16) type in the GNU Fortran compiler. Homepage: http://gcc.gnu.org/ Package: libvorbisfile3 --Plus--(0%)
Afin de connaître le nombre total de paquets installés, utilisez la commande suivante :
root@debian9:~# dpkg --get-selections | wc -l 1293
Imaginons maintenant que vous souhaitez vérifier si un paquet contenant la chaîne de caractères zip soit déjà installé sur la machine. Dans ce cas, il convient d'abord d'utiliser la commande suivante :
root@debian9:~# dpkg --get-selections | grep zip bzip2 install gzip install p7zip install p7zip-full install unzip install
Afin de connaître le statut de du paquet gzip, il convient de saisir la commande suivante :
root@debian9:~# dpkg -s gzip Package: gzip Essential: yes Status: install ok installed Priority: required Section: utils Installed-Size: 231 Maintainer: Bdale Garbee <bdale@gag.com> Architecture: amd64 Source: gzip (1.6-5) Version: 1.6-5+b1 Depends: dpkg (>= 1.15.4) | install-info Pre-Depends: libc6 (>= 2.17) Suggests: less Description: GNU compression utilities This package provides the standard GNU file compression utilities, which are also the default compression tools for Debian. They typically operate on files with names ending in '.gz', but can also decompress files ending in '.Z' created with 'compress'.
Afin de lister tous les fichiers installés par le paquet gzip, utilisez la commande suivante :
root@debian9:~# dpkg -L gzip /. /bin /bin/gunzip /bin/gzexe /bin/gzip /bin/uncompress /bin/zcat /bin/zcmp /bin/zdiff /bin/zegrep /bin/zfgrep /bin/zforce /bin/zgrep /bin/zless /bin/zmore /bin/znew /usr /usr/share /usr/share/doc /usr/share/doc/gzip /usr/share/doc/gzip/README-release /usr/share/doc/gzip/README.gz /usr/share/doc/gzip/TODO /usr/share/doc/gzip/changelog.Debian.amd64.gz /usr/share/doc/gzip/changelog.Debian.gz /usr/share/doc/gzip/changelog.gz /usr/share/doc/gzip/copyright /usr/share/info /usr/share/info/gzip.info.gz /usr/share/lintian /usr/share/lintian/overrides /usr/share/man /usr/share/man/man1 /usr/share/man/man1/gzexe.1.gz /usr/share/man/man1/gzip.1.gz /usr/share/man/man1/zdiff.1.gz /usr/share/man/man1/zforce.1.gz /usr/share/man/man1/zgrep.1.gz /usr/share/man/man1/zless.1.gz /usr/share/man/man1/zmore.1.gz /usr/share/man/man1/znew.1.gz /usr/share/man/man1/gunzip.1.gz /usr/share/man/man1/uncompress.1.gz /usr/share/man/man1/zcat.1.gz /usr/share/man/man1/zcmp.1.gz /usr/share/man/man1/zegrep.1.gz /usr/share/man/man1/zfgrep.1.gz
A l'inverse, si vous connaissez le nom d'un fichier et vous souhaitez savoir quel paquet l'a installé, utilisez la commande suivante :
root@debian9:~# dpkg -S /bin/zfgrep gzip: /bin/zfgrep
La Commande dselect
La commande dselect est un outil interactif utilisé pour gérer, installer et désinstaller des paquets. C'est un Front End à la commande dpkg et est lancé sans options.
La commande dselect n'est pas installé par défaut. Il convient donc d'utiliser la commande apt-get pour l'installer :
root@debian9:~# apt-get install dselect Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Les NOUVEAUX paquets suivants seront installés : dselect 0 mis à jour, 1 nouvellement installés, 0 à enlever et 96 non mis à jour. Il est nécessaire de prendre 1 285 ko dans les archives. Après cette opération, 2 561 ko d'espace disque supplémentaires seront utilisés. Réception de:1 http://ftp.fr.debian.org/debian stretch/main amd64 dselect amd64 1.18.25 [1 285 kB] 1 285 ko réceptionnés en 0s (1 837 ko/s) Sélection du paquet dselect précédemment désélectionné. (Lecture de la base de données... 91043 fichiers et répertoires déjà installés.) Préparation du dépaquetage de .../dselect_1.18.25_amd64.deb ... Dépaquetage de dselect (1.18.25) ... Paramétrage de dselect (1.18.25) ... Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ...
Lancez maintenant dselect :
Interface de gestion de paquets Debian « dselect » version 1.18.25 (amd64). * 0. [A]ccéder Choisir la méthode d'accès à utiliser 1. [M]ise à j Mise à jour de l'information sur les paquets disponibles, si 2. [S]électio Sélection des paquets que vous désirez avoir sur votre syst 3. [I]nstaller Installation et mise à niveau des paquets désirés. 4. [C]onfigure Configuration de tout paquet non configuré. 5. [R]etirer Suppression des applications non désirées. 6. [Q]uitter Quitter dselect. Utilisez ^P et ^N, les touches fléchées, les lettres initiales ou les chiffres p our vous déplacer ; Appuyez sur <Entrée> pour confirmer la sélection. ^L pour redessiner l'écran. Copyright (C) 1994-1996 Ian Jackson. Copyright (C) 2000,2001 Wichert Akkerman. Ce programme est un logiciel libre ; prière de consulter la « GNU General Public License » version 2 ou supérieure pour prendre connaissance des conditions de reproduction. AUCUNE garantie n'est offerte.
A faire - Notez les instructions en bas de l'écran et expérimentez avec l'interface.
La Commande apt-get
APT ou en anglais Advanced Package Tool est un gestionnaire de paquets de haut niveau capable de résoudre automatiquement les problèmes de dépendances entre les paquets.
La commande apt-get prend la forme suivante :
# apt-get <options> <commande> <paquet(s)> [Entrée]
Les options et commandes de la commande apt-get sont :
root@debian9:~# apt-get --help apt 1.4.9 (amd64) Usage: apt-get [options] command apt-get [options] install|remove pkg1 [pkg2 ...] apt-get [options] source pkg1 [pkg2 ...] apt-get is a command line interface for retrieval of packages and information about them from authenticated sources and for installation, upgrade and removal of packages together with their dependencies. Most used commands: update - Récupère les nouvelles listes de paquets upgrade - Réalise une mise à jour install - Installe de nouveaux paquets (pkg1 est libc6 et non libc6.deb) remove - Supprime des paquets purge - Supprime des paquets et leurs fichiers de configuration autoremove - Supprime automatiquement les dépendances inutilisés dist-upgrade - Met à jour la distribution, reportez-vous à apt-get(8) dselect-upgrade - Suit les sélections de dselect build-dep - Configure build-dependencies pour les paquets sources clean - Supprime dans le cache local tous les fichiers téléchargés autoclean - Supprime dans le cache local les fichiers inutiles check - Vérifie qu'il n'y a pas de rupture de dépendances source - Télécharge les archives de sources download - Télécharge le paquet binaire dans le répertoire courant changelog - Télécharge et affiche le journal des modifications (« changelog ») du paquet indiqué See apt-get(8) for more information about the available commands. Configuration options and syntax is detailed in apt.conf(5). Information about how to configure sources can be found in sources.list(5). Package and version choices can be expressed via apt_preferences(5). Security details are available in apt-secure(8). Cet APT a les « Super Cow Powers »
Configuration
APT peut être configuré par un fichier centralisé /etc/apt/apt.conf. Un exemple est fourni :
root@debian9:~# cat /usr/share/doc/apt/examples/apt.conf // $Id: apt.conf,v 1.43 1999/12/06 02:19:38 jgg Exp $ /* This file is a sample configuration file with a few harmless sample options. */ APT { // Options for apt-get Get { Download-Only "false"; }; }; // Options for the downloading routines Acquire { Retries "0"; }; // Things that effect the APT dselect method DSelect { Clean "auto"; // always|auto|prompt|never }; DPkg { // Probably don't want to use force-downgrade.. Options {"--force-overwrite";} }
D'autres fichiers de configuration se trouvent dans le répertoire /etc/apt/apt.conf.d/ :
root@debian9:~# ls /etc/apt/apt.conf.d/ 00CDMountPoint 01autoremove 20listchanges 70debconf 00trustcdrom 01autoremove-kernels 20packagekit
Le contenu de ces fichiers sont :
root@debian9:~# cat /etc/apt/apt.conf.d/00CDMountPoint Acquire::cdrom { mount "/media/cdrom"; }; Dir::Media::MountPath "/media/cdrom"; root@debian9:~# root@debian9:~# cat /etc/apt/apt.conf.d/01autoremove APT { NeverAutoRemove { "^firmware-linux.*"; "^linux-firmware$"; }; VersionedKernelPackages { # linux kernels "linux-image"; "linux-headers"; "linux-image-extra"; "linux-signed-image"; # kfreebsd kernels "kfreebsd-image"; "kfreebsd-headers"; # hurd kernels "gnumach-image"; # (out-of-tree) modules ".*-modules"; ".*-kernel"; "linux-backports-modules-.*"; # tools "linux-tools"; }; Never-MarkAuto-Sections { "metapackages"; "contrib/metapackages"; "non-free/metapackages"; "restricted/metapackages"; "universe/metapackages"; "multiverse/metapackages"; }; Move-Autobit-Sections { "oldlibs"; "contrib/oldlibs"; "non-free/oldlibs"; "restricted/oldlibs"; "universe/oldlibs"; "multiverse/oldlibs"; }; }; root@debian9:~# root@debian9:~# cat /etc/apt/apt.conf.d/01autoremove-kernels // DO NOT EDIT! File autogenerated by /etc/kernel/postinst.d/apt-auto-removal APT::NeverAutoRemove { "^linux-image-4\.9\.0-8-amd64$"; "^linux-headers-4\.9\.0-8-amd64$"; "^linux-image-extra-4\.9\.0-8-amd64$"; "^linux-signed-image-4\.9\.0-8-amd64$"; "^kfreebsd-image-4\.9\.0-8-amd64$"; "^kfreebsd-headers-4\.9\.0-8-amd64$"; "^gnumach-image-4\.9\.0-8-amd64$"; "^.*-modules-4\.9\.0-8-amd64$"; "^.*-kernel-4\.9\.0-8-amd64$"; "^linux-backports-modules-.*-4\.9\.0-8-amd64$"; "^linux-tools-4\.9\.0-8-amd64$"; }; /* Debug information: # dpkg list: iF linux-image-4.9.0-8-amd64 4.9.130-2 amd64 Linux 4.9 for 64-bit PCs iU linux-image-amd64 4.9+80+deb9u6 amd64 Linux for 64-bit PCs (meta-package) # list of installed kernel packages: 4.9.0-8-amd64 4.9.130-2 # list of different kernel versions: 4.9.130-2 # Installing kernel: 4.9.130-2 (4.9.0-8-amd64) # Running kernel: 4.9.130-2 (4.9.0-8-amd64) # Last kernel: 4.9.130-2 # Previous kernel: # Kernel versions list to keep: 4.9.130-2 # Kernel packages (version part) to protect: 4\.9\.0-8-amd64 */ root@debian9:~# root@debian9:~# cat /etc/apt/apt.conf.d/70debconf // Pre-configure all packages with debconf before they are installed. // If you don't like it, comment it out. DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};
Dépôts
Important - Un dépôt est un lieu de stockage de paquets binaires prêts à installer. Un dépôt peut être le DVD d'installation de la distribution, un dossier sur disque dur ou bien des serveurs distants accessibles par Internet.
Les dépôts de paquets sont spécifiés soit dans le fichier /etc/apt/sources.list, soit dans un fichier par dépôt stocké dans le répertoire /etc/apt/sources.list.d :
root@debian9:~# cat /etc/apt/sources.list # # deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main #deb cdrom:[Debian GNU/Linux 9.6.0 _Stretch_ - Official amd64 NETINST 20181110-11:34]/ stretch main deb http://ftp.fr.debian.org/debian/ stretch main deb-src http://ftp.fr.debian.org/debian/ stretch main deb http://security.debian.org/debian-security stretch/updates main deb-src http://security.debian.org/debian-security stretch/updates main # stretch-updates, previously known as 'volatile' deb http://ftp.fr.debian.org/debian/ stretch-updates main deb-src http://ftp.fr.debian.org/debian/ stretch-updates main
Chaque ligne de ce fichier comporte quatre champs :
- Le premier champ deb ou deb-src
- indique si la source concerne des paquets binaires à installer ou les sources des paquets
- Le deuxième champ indique l'URL de la source
- indique file:// ou copy:// pour un répertoire local
- indique cdrom:// pour un CD ou DVD
- indique http:// pour un serveur web
- indique ftp:// pour un serveur ftp
- Le troisième champ indique la branche Debian
- indique stable, testing ou unstable ou leur nom de correspondant tel squeeze
- Le quatrième champs indique une section de paquets
- main
- contrib
- non-free
- non-US
Important - Il est possible d'ajouter une source directement en éditant le fichier /etc/apt/sources.list, en créant un fichier spécifique dans le répertoire /etc/apt/sources.list.d ou en utilisant la commande apt-setup.
La mise à jour de la base de références de la description des paquets est effectuée un utilisant la commande suivante :
root@debian9:~# apt-get update Atteint:1 http://security.debian.org/debian-security stretch/updates InRelease Ign:2 http://ftp.fr.debian.org/debian stretch InRelease Réception de:3 http://ftp.fr.debian.org/debian stretch-updates InRelease [91,0 kB] Atteint:4 http://ftp.fr.debian.org/debian stretch Release 91,0 ko réceptionnés en 0s (145 ko/s) Lecture des listes de paquets... Fait
Utilisation
Les commandes les plus utilisées d'apt-get sont :
Commande | Description |
---|---|
install | Installer un ou plusieurs paquets. |
upgrade | Mettre à jour les paquets installés. |
remove | Supprimer un paquet. |
purge | Supprimer un paquet et ses fichiers de configuration. |
LAB #5 - Utiliser la commande apt-get
Commencez par installer le paquet mc :
root@debian9:~# apt-get install mc Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait The following additional packages will be installed: mc-data Paquets suggérés : arj catdvi | texlive-binaries dbview djvulibre-bin genisoimage gv imagemagick libaspell-dev links | w3m | lynx odt2txt poppler-utils python-boto python-tz zip Les NOUVEAUX paquets suivants seront installés : mc mc-data 0 mis à jour, 2 nouvellement installés, 0 à enlever et 96 non mis à jour. Il est nécessaire de prendre 1 780 ko dans les archives. Après cette opération, 7 175 ko d'espace disque supplémentaires seront utilisés. Souhaitez-vous continuer ? [O/n] y Réception de:1 http://ftp.fr.debian.org/debian stretch/main amd64 mc-data all 3:4.8.18-1 [1 267 kB] Réception de:2 http://ftp.fr.debian.org/debian stretch/main amd64 mc amd64 3:4.8.18-1 [513 kB] 1 780 ko réceptionnés en 0s (2 484 ko/s) Sélection du paquet mc-data précédemment désélectionné. (Lecture de la base de données... 91128 fichiers et répertoires déjà installés.) Préparation du dépaquetage de .../mc-data_3%3a4.8.18-1_all.deb ... Dépaquetage de mc-data (3:4.8.18-1) ... Sélection du paquet mc précédemment désélectionné. Préparation du dépaquetage de .../mc_3%3a4.8.18-1_amd64.deb ... Dépaquetage de mc (3:4.8.18-1) ... Traitement des actions différées (« triggers ») pour mime-support (3.60) ... Traitement des actions différées (« triggers ») pour desktop-file-utils (0.23-1) ... Paramétrage de mc-data (3:4.8.18-1) ... Traitement des actions différées (« triggers ») pour man-db (2.7.6.1-2) ... Traitement des actions différées (« triggers ») pour hicolor-icon-theme (0.15-1) ... Paramétrage de mc (3:4.8.18-1) ... update-alternatives: utilisation de « /usr/bin/mcview » pour fournir « /usr/bin/view » (view) en mode automatique
La ré-installation d'un paquet est effectuée un utilisant la commande suivante :
root@debian9:~# apt-get --reinstall install mc Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait 0 mis à jour, 0 nouvellement installés, 1 réinstallés, 0 à enlever et 96 non mis à jour. Il est nécessaire de prendre 0 o/513 ko dans les archives. Après cette opération, 0 o d'espace disque supplémentaires seront utilisés. (Lecture de la base de données... 91494 fichiers et répertoires déjà installés.) Préparation du dépaquetage de .../mc_3%3a4.8.18-1_amd64.deb ... Dépaquetage de mc (3:4.8.18-1) sur (3:4.8.18-1) ... Traitement des actions différées (« triggers ») pour mime-support (3.60) ... Traitement des actions différées (« triggers ») pour desktop-file-utils (0.23-1) ... Paramétrage de mc (3:4.8.18-1) ...
La suppression complète d'un paquet, y compris les fichiers de configuration éventuellement modifiés est effectuée un utilisant la commande suivante :
root@debian9:~# apt-get --purge remove mc Lecture des listes de paquets... Fait Construction de l'arbre des dépendances Lecture des informations d'état... Fait Le paquet suivant a été installé automatiquement et n'est plus nécessaire : mc-data Veuillez utiliser « apt autoremove » pour le supprimer. Les paquets suivants seront ENLEVÉS : mc* 0 mis à jour, 0 nouvellement installés, 1 à enlever et 96 non mis à jour. Après cette opération, 1 465 ko d'espace disque seront libérés. Souhaitez-vous continuer ? [O/n] y (Lecture de la base de données... 91494 fichiers et répertoires déjà installés.) Suppression de mc (3:4.8.18-1) ... update-alternatives: utilisation de « /usr/bin/vim.tiny » pour fournir « /usr/bin/view » (view) en mode automatique Traitement des actions différées (« triggers ») pour mime-support (3.60) ... Traitement des actions différées (« triggers ») pour desktop-file-utils (0.23-1) ... (Lecture de la base de données... 91404 fichiers et répertoires déjà installés.) Purge des fichiers de configuration de mc (3:4.8.18-1) ...
Les paquets téléchargés d'une source distante ou via une source copy:// sont stockés dans le répertoire /var/cache/apt/archives. Les paquets partiellement téléchargés ou copiés sont stockés dans le répertoire /var/cache/apt/archives/partial.
root@debian9:~# ls /var/cache/apt/archives/ binutils_2.28-5_amd64.deb libasan3_6.3.0-18+deb9u1_amd64.deb libgcc-6-dev_6.3.0-18+deb9u1_amd64.deb libubsan0_6.3.0-18+deb9u1_amd64.deb partial curl_7.52.1-5+deb9u9_amd64.deb libatomic1_6.3.0-18+deb9u1_amd64.deb libitm1_6.3.0-18+deb9u1_amd64.deb lock dselect_1.18.25_amd64.deb libcc1-0_6.3.0-18+deb9u1_amd64.deb liblsan0_6.3.0-18+deb9u1_amd64.deb manpages-dev_4.10-2_all.deb gcc_4%3a6.3.0-4_amd64.deb libcilkrts5_6.3.0-18+deb9u1_amd64.deb libmpx2_6.3.0-18+deb9u1_amd64.deb mc_3%3a4.8.18-1_amd64.deb gcc-6_6.3.0-18+deb9u1_amd64.deb libcurl3_7.52.1-5+deb9u9_amd64.deb libtsan0_6.3.0-18+deb9u1_amd64.deb mc-data_3%3a4.8.18-1_all.deb
Pour nettoyer le cache il convient d'utiliser la commande suivante :
root@debian9:~# apt-get clean root@debian9:~# ls /var/cache/apt/archives/ lock partial
Pour mettre à jour les paquets déjà installés, il convient d'utiliser une de deux commandes apt-get :
- upgrade,
- dist-upgrade.
La deuxième commande met à jour une distribution complète, c'est-à-dire d'installer les mises à jour des paquets déjà installés et installer des nouveaux paquets ainsi que leur dépendances.
A faire - Consultez l'APT HOWTO pour vous renseigner sur les autres commandes et options.
LAB #5 - Utiliser la commande apt-cache
La commande apt-cache permet de se renseigner sur les paquetages connus à APT.
La commande apt-cache prend la forme suivante :
# apt-cache <options> <commande> <paquet(s)> [Entrée]
Les options et les commandes de la commande apt-cache sont :
root@debian9:~# apt-cache --help apt 1.4.9 (amd64) Usage: apt-cache [options] command apt-cache [options] show pkg1 [pkg2 ...] apt-cache queries and displays available information about installed and installable packages. It works exclusively on the data acquired into the local cache via the 'update' command of e.g. apt-get. The displayed information may therefore be outdated if the last update was too long ago, but in exchange apt-cache works independently of the availability of the configured sources (e.g. offline). Most used commands: showsrc - Affiche les enregistrements des sources search - Cherche une expression rationnelle dans la liste des paquets depends - Affiche toutes les dépendances d'un paquet rdepends - Affiche les dépendances inverses d'un paquet show - Affiche la description du paquet pkgnames - Liste le nom de tous les paquets du système policy - Affiche l'épinglage (Pin) en vigueur See apt-cache(8) for more information about the available commands. Configuration options and syntax is detailed in apt.conf(5). Information about how to configure sources can be found in sources.list(5). Package and version choices can be expressed via apt_preferences(5). Security details are available in apt-secure(8).
Les commandes les plus utilisées d'apt-cache sont :
Commande | Description |
---|---|
stats | Affiche quelques statistiques de base. |
search | Cherche une expression rationnelle dans la liste des paquets. |
show | Affiche la description du paquet. |
depends | Affiche toutes les dépendances d'un paquet. |
Utilisez la commande stats de la commande apt-cache pour obtenir des statistiques sur les paquets :
root@debian9:~# apt-cache stats Nombre total de paquets : 65317 (1 306 k) Nombre total de structures de paquets : 65322 (2 874 k) Paquets ordinaires : 50238 Paquets entièrement virtuels : 424 Paquets virtuels simples : 5490 Paquets virtuels mixtes : 636 Manquants : 8534 Nombre de versions distinctes : 52411 (4 193 k) Nombre de descriptions distinctes : 118225 (2 837 k) Nombre de dépendances : 328341/88670 (7 986 k) Nombre de relations version/fichier : 55240 (1 326 k) Nombre de relations description/fichier : 52689 (1 265 k) Nombre de relations « Provides » : 8946 (215 k) Nombre de motifs rationnels : 147962 (3 179 k) Espace disque gaspillé : 26,2 k Total de l'espace attribué : 25,6 M Total buckets in PkgHashTable: 50503 Unused: 13869 Used: 36634 Utilization: 72.5383% Average entries: 1.7831 Longest: 8 Shortest: 1 Total buckets in GrpHashTable: 50503 Unused: 13869 Used: 36634 Utilization: 72.5383% Average entries: 1.78296 Longest: 8 Shortest: 1
A faire - Utilisez le manuel d'apt-cache pour trouver les définitions des termes Normal packages, Pure virtual packages, Single virtual packages et Mixed virtual packages.
Recherchez maintenant la chaîne mc dans la liste des paquets :
root@debian9:~# apt-cache search mc | more alsa-oss - encapsuleur ALSA pour applications OSS amule-emc - liste les liens ed2k dans les fichiers emulecollection apel - bibliothèque portable pour emacsen apmd - utilitaires de gestion avancée de l'énergie (APM) appstream - gestion de métadonnées de composants logiciels ap-utils - utilitaires SNMP de point d'accès pour Linux archipel-agent-vmcasting - orchestration de machine virtuelle - agent Vmcasting ardour - station de travail audionumérique asterisk - Autocommutateur téléphonique (PBX) Open Source auto-07p - logiciel pour les problèmes de continuation et de bifurcation en équations différentielles ordinaires auto-multiple-choice - gestion de QCM auto-multiple-choice-common - Auto Multiple Choice - fichiers indépendants de l'architecture auto-multiple-choice-doc - Auto Multiple Choice - documentation HTML auto-multiple-choice-doc-pdf - Auto Multiple Choice - documentation PDF beast2-mcmc - inférence phylogénétique bayésienne MCMC beast2-mcmc-doc - inférence phylogénétique bayésienne MCMC – documentation beast2-mcmc-examples - inférence phylogénétique bayésienne MCMC – données d'exemple beast-mcmc - inférence phylogénétique bayésienne MCMC beast-mcmc-doc - inférence phylogénétique bayésienne MCMC – documentation beast-mcmc-examples - inférence phylogénétique bayésienne MCMC – données d'exemple cbmc - vérificateur de modèle borné pour les programmes C et C++ cccc - compteur de code C et C++, outil de métrique claws-mail-spam-report - greffon de rapport de pourriels pour Claws Mail cl-closer-mop - bibliothèque AMOP d'implémentation croisée cl-mcclim - boîte à outils d'interface utilisateur graphique Common Lisp cl-mcclim-doc - paquet d'interface utilisateur graphique pour les programmes Common Lisp cl-mcclim-examples - boîte à outils d'interface utilisateur graphique Common Lisp cl-swank - mode supérieur d'interaction LISP pour Emacs — serveur Lisp cl-trivial-backtrace - génération d'une trace Common Lisp portable cl-uffi - bibliothèque de fonction externe universelle pour Common Lisp cmucl-source - sources LISP de CMUCL collectd-core - démon de statistiques et surveillance – système central colortest - outils pour tester la capacité en couleur d'un terminal comgt - outil de contrôle de carte de donnée Vodafone et Option GlobeTrotter complexity - outil d'analyse de complexité pour les fonctions de programme C complexity-doc - outil d'analyse de complexité pour les fonctions de programme C – documentation cpuid - outil pour lister les informations CPUID x86 sur le(s) processeur(s) discover-data - listes de données pour Discover, le système d'identification de matériel dreamchess - jeu d’échecs 3D --Plus--
Pour être plus précis dans la recherche, il est nécessaire de rechercher une phrase clef :
root@debian9:~# apt-cache search "midnight commander" avfs - système de fichiers virtuel pour accéder aux archives, images disque, endroits distants gnome-commander - gestionnaires de fichiers pour GNOME junior-system - outils système Debian Jr. krusader - Gestionnaire de fichiers à deux volets (dans le style de Commander) lfm - gestionnaire de fichiers simple et puissant pour la console UNIX mc - Midnight Commander - gestionnaire de fichiers évolué mc-data - Midnight Commander - gestionnaire de fichiers évolué –⋅fichiers de données pilot - Navigateur simple de fichiers pour Alpine, client de courriel en mode texte tuxcmd - gestionnaire de fichiers à double panneau utilisant GTK+ 2 gnome-commander-data - Data files for GNOME Commander gnome-commander-dbg - Debugging symbols for gnome-commander moc - ncurses based console audio player ranger - File manager with an ncurses frontend written in Python
Afficher maintenant les informations concernant le paquet mc :
root@debian9:~# apt-cache show mc Package: mc Version: 3:4.8.18-1 Installed-Size: 1431 Maintainer: Debian MC Packaging Group <pkg-mc-devel@lists.alioth.debian.org> Architecture: amd64 Provides: mcedit Depends: e2fslibs (>= 1.37), libc6 (>= 2.15), libglib2.0-0 (>= 2.35.9), libgpm2 (>= 1.20.4), libslang2 (>= 2.2.4), libssh2-1 (>= 1.2.8), mc-data (= 3:4.8.18-1) Recommends: mime-support, perl, unzip Suggests: arj, bzip2, catdvi | texlive-binaries, dbview, djvulibre-bin, file, genisoimage, gv, imagemagick, libaspell-dev, links | w3m | lynx, odt2txt, poppler-utils, python, python-boto, python-tz, xpdf | pdf-viewer, zip Description-fr: Midnight Commander - gestionnaire de fichiers évolué GNU Midnight Commander est un gestionnaire de fichiers en mode texte plein écran. Il utilise une interface à deux volets et un sous-shell pour l'exécution de commandes. Il comporte un éditeur de fichiers avec colorisation syntaxique ainsi qu'un afficheur de fichiers gérant les fichiers binaires. Il fournit également VFS (« Virtual Filesystem », système de fichiers virtuel) qui permet de manipuler les fichiers situés sur des systèmes distants (p. ex. de serveurs FTP ou SSH) ainsi que les fichiers inclus dans des archives. Description-md5: 252a5c5aeeb7425db45357d4ab8aa55f Homepage: http://www.midnight-commander.org Tag: admin::filesystem, implemented-in::c, implemented-in::perl, interface::commandline, interface::text-mode, role::program, scope::application, suite::gnu, uitoolkit::ncurses, use::browsing, use::editing, use::organizing, works-with::archive, works-with::file Section: utils Priority: optional Filename: pool/main/m/mc/mc_4.8.18-1_amd64.deb Size: 512534 MD5sum: 0d114b3f03ec94fa58f4f0cb38a6edfd SHA256: 3e360d9848a0d44519f3e041b97cde6e88cd704d7b2f5efb3ffeede517b062ae
Dernièrement, visualisez les dépendances du paquet mc :
root@debian9:~# apt-cache depends mc mc Dépend: e2fslibs Dépend: libc6 Dépend: libglib2.0-0 Dépend: libgpm2 Dépend: libslang2 Dépend: libssh2-1 Dépend: mc-data Recommande: mime-support Recommande: perl Recommande: unzip Suggère: arj Suggère: bzip2 |Suggère: catdvi Suggère: texlive-binaries Suggère: dbview Suggère: djvulibre-bin Suggère: file Suggère: genisoimage Suggère: gv Suggère: imagemagick graphicsmagick-imagemagick-compat imagemagick-6.q16 Suggère: libaspell-dev |Suggère: links |Suggère: w3m Suggère: lynx Suggère: odt2txt Suggère: poppler-utils Suggère: python Suggère: python-boto Suggère: python-tz |Suggère: xpdf Suggère: <pdf-viewer> atril evince gv mupdf okular viewpdf.app xpdf zathura-pdf-poppler Suggère: zip
Les deux lignes suivantes :
|Suggère: xpdf Suggère: <pdf-viewer>
indiquent soit xpdf soit <pdf-viewer>
Copyright © 2023 Hugh Norris.