WIKI Retour au Portfolio

Dernière mise à jour : 23 juin 2026

Fiche concise — RHCSA (EX200, RHEL 9)

Révision dernière minute, cours 1→7. Exam 100% pratique. RHEL 9 = dnf/ip/nmcli/ss/firewall-cmd/chrony (PAS yum/ifconfig/netstat/iptables/ntpd).

INTRO / ECOSYSTEME Linux = OS open source inspiré UNIX / distrib = kernel + logiciels + pkg manager + cfg défaut. Upstream→downstream : Fedora → CentOS Stream → RHEL → Rocky/AlmaLinux (rebuilds gratuits 1:1). 🚨 PIEGE CentOS : avant 2019 CentOS Linux = downstream (clone RHEL), DEPUIS CentOS Stream = UPSTREAM (preview RHEL) → ya plus de clone → naissance Rocky/Alma. RHEL : 1ère version 1993, nouvelle majeure ~3 ans, cible exam = RHEL 9. Compte Red Hat Developer (gratuit) → télécharge ISO RHEL 9 x86_64 (~8 Go).

INSTALL / BOOT Installateur = Anaconda : Installation Destination (reclaim disque) / Root password / user admin. Partitionnement : Custom → Standard Partition → créer mountpoints (/boot 500M, / , swap, /home). DEFAULT RHEL 9 auto = LVM + XFS. Partition EFI (/boot/efi ~600M FAT) OBLIGATOIRE si UEFI (cas std), absente en BIOS legacy. Boot = GRUB2 (entrée Linux normale + entrée rescue). Reboot après install. Doc/aide : man ls / ls --help / info dnf / /usr/share/doc. Identité : whoami, hostname, uname -r.

SHELL / TERMINAL Bash = shell DEFAULT, GNOME = GUI défaut. who/w (qui connecté + activité), sudo chvt 4 (= Ctrl+Alt+F4) bascule tty virtuel. tty1 = GNOME, tty2-6 = consoles texte. Anatomie : ls -l /etc → ls cmd, -l option, /etc argument. Globbing (interprété par le SHELL) : ls a? (1 char), ls [a-e]*, touch file{1..9} (séquence), {a,b,c} (liste), $(which passwd) (command substitution). Quotes : "$VAR" interprète variable + protège espaces / '$VAR' et \$ = littéral.

MAN / AIDE man 5 passwd (format fichier), man -a passwd (toutes sections), man -k user = apropos user (mot-clé via mandb), sudo mandb reconstruit la base. Sections : 1 = commandes, 5 = formats de fichiers, 8 = admin (root). Navigation : /avant ?arrière Gfin gdébut qquitter.

VI / VIM vi minimal sous RHEL 9 → paquet complet = vim-enhanced (dnf install vim-enhanced). vimtutor = tuto. Modes : Esc cmd / i,a insert / o nouvelle ligne+insert. :wq save+quit, :q! quit sans save. dd couper ligne, yy copier, p coller, u undo, Ctrl+R redo, gg/G début/fin, /,? recherche, ^/$ début/fin ligne, w mot suivant. :%s/old/new/g substituer tout, :set number numéroter.

REDIRECTIONS / PIPES Flux : STDIN(0), STDOUT(1), STDERR(2). > écrase (🚨 sans avertissement), >> ajoute, 2> erreurs, 2>/dev/null jette erreurs, &> stdout+stderr, < fichier en stdin, | pipe. echo x > f / cat f | grep mot / ls -l | grep user.

HISTORIQUE / SHORTCUTS / ALIAS Historique dans ~/.bash_history. history, !42 rejoue n°42, !! dernière, history -c vide mémoire, history -d 5. Vars HISTSIZE (mémoire) / HISTFILESIZE (fichier). Shortcuts : Ctrl+C kill, Ctrl+D EOF/logout, Ctrl+A/Ctrl+E début/fin ligne, Ctrl+R reverse-search, Ctrl+L clear, Ctrl+U efface jusqu'au début, Alt+B/Alt+F mot. alias del='rm -rf' / unalias del / alias liste. 🚨 PAS d'alias dangereux.

VARIABLES / STARTUP FILES env liste, color=blue (locale), export color=green (héritée sous-shells). /etc/profile (login shell, tous users) / /etc/bashrc (sous-shell non-login) / ~/.bash_profile (login par user) / ~/.bashrc (sous-shell par user). Vars/alias perso persistants → ~/.bashrc. source f = . f (exécute dans shell COURANT, vars persistent).

FICHIERS / FHS / NAVIGATION Racine /. /etc cfg, /usr programmes, /var données variables (logs/spool), /tmp temp inscriptible par tous, /home users. pwd,cd,ls,mkdir,cp src dst,mv,rmdir (VIDE only),rm -rf (🚨 aucune confirmation),touch,stat (inode/dates/contexte SELinux).

TROUVER FICHIERS which ls (binaire dans PATH), locate hosts (base indexée → updatedb rafraîchit), find / -name hosts (temps réel, lent). find / -name hosts 2>/dev/null, find / -type f -size +1000M, find /etc -size +1k -exec grep -l mot {} \; -exec cp {} dst/ \;. \; clôt -exec, grep -l = noms seulement.

LIENS ln cible lien (hard link, MEME inode, survit si original supprimé, PAS cross-FS) / ln -s cible lien (symbolique, inode différent, casse si original supprimé, cross-FS OK). ls -il (inodes), l en 1ère colonne ls -l = symlink.

ARCHIVAGE / COMPRESSION tar -cvf a.tar dir (créer), -tvf (lister), -xvf (extraire). Compression : -z gzip (.tar.gz, le + courant/rapide), -j bzip2 (.tar.bz2), -J xz (.tar.xz, meilleur taux). tar -czvf a.tar.gz dir. gzip f/gunzip f.gz, bzip2 f/bunzip2.

TEXTE (grep/sed/awk/cut) more/less (less = avant/arrière), head -n5, tail -n5, tail -f (logs), cat (-A non-imprimables, -b numérote, -s compresse vides). cut -d: -f1 /etc/passwd, tr a-z A-Z, sort, uniq (après sort), wc -l, tee (écran+fichier), diff/cmp. grep : -v exclure, -i insensible casse, -R récursif, -l noms seulement, -A5 -B4 contexte. BRE : ^début $fin \blimite mot \{3\}n occ *0+. ERE (grep -E) : +1+, ?0/1, .1 char, \| alternance → grep -E 'colou?r'. awk : awk -F: '{print $4}', '{print $NF}' (dernière col), '/mot/ {print $1}'. sed : sed -n '5p' (imprime ligne 5), sed -i 's/old/new/g' f (🚨 -i modifie le disque, tester sans -i avant), sed -i '10d' f (suppr ligne 10).

USERS / GROUPS /etc/passwd : Name:Passwd:UID:GID:GECOS:DIR:SHELL. /etc/shadow = mdp chiffré. /etc/group = groupes secondaires. UID 0 = root. useradd nom, usermod, userdel -r nom (supprime /home + mail spool), passwd nom, id user. useradd lori -u 2000 -s /sbin/nologin (UID + shell nologin). useradd -m -s /bin/bash bob (-m crée home). Défauts : useradd -D, /etc/login.defs (UID min/max, exp mdp), /etc/default/useradd, /etc/skel (copié dans /home des NOUVEAUX users). Limiter : usermod -L/-U (verrouille/déverrouille), usermod -e 2024-01-01 (expiration), usermod -s /sbin/nologin. Groupes : groupadd/groupdel/groupmod, usermod -aG groupe user (secondaire). 🚨 usermod -G SANS -a ECRASE la liste (retire des autres) → TOUJOURS -aG. Mdp : chage user (interactif), chage -l user (expiration), echo pass | passwd --stdin anna (scripting), passwd -l user (verrouille mdp), règles avancées via PAM.

PERMISSIONS / ACL UGO : User/Group/Others. ls -l afficher. chown user:group f, chown :group f, chgrp. Valeurs : read 4, write 2, execute 1. chmod 750 f, chmod +x, chmod g+w, chmod u-w. X (maj) sur dir = exec dossiers seulement. Special : SGID chmod g+s dir (fichiers héritent du GROUPE du dir, partage équipe), Sticky chmod +t dir (seul propriétaire supprime, cf /tmp), chmod 3770 (3=SGID+sticky). Défauts : fichiers 666, dossiers 777. umask retranche (effectif = défaut − umask). umask 027. Permanent → /etc/bashrc ou ~/.bashrc. ACL : getfacl f, setfacl -m u:alice:rw f, setfacl -m d:u:alice:rw dir (default/héritage).

SUDO su - nom (env complet), su - (root), sudo -i (shell root), sudo cmd. visudo édite /etc/sudoers (vérif syntaxe). %wheel ALL=(ALL) ALL (groupe wheel a sudo), Defaults timestamp_timeout=60, student ALL=/sbin/useradd (cmd unique), %users ALL=/bin/mount /dev/sdb. Organisé : fichiers dans /etc/sudoers.d/. hamid ALL=/usr/bin/passwd, !/usr/bin/passwd root (autorisé SAUF root). 🚨 NE PAS activer NOPASSWD: ALL.

PROCESSUS / SIGNAUX / PRIORITES Chaque tâche = process + PID. Jobs shell : cmd & (arrière-plan), Ctrl+Z+bg, jobs, fg %1, nohup cmd & (survit fermeture terminal). Etats : R runnable, S interruptible (attend), D uninterruptible (ne répond pas aux signaux), T stopped (Ctrl+Z), Z zombie, X dead. 🚨 ZOMBIE : fini mais parent n'a pas collecté statut → déjà mort, occupe juste un PID. Solution : tuer le parent (init/systemd PID 1 l'adopte+reap), ou kill -SIGCHLD parent (souvent ignoré). ps aux (BSD), ps -fax (hiérarchie), ps -fU hamid, ps -ef, ps -eo pid,ppid,user,cmd, ps -u user, pkill -u user. Signaux : kill PID (SIGTERM 15, propre, DEFAULT), kill -9 PID (SIGKILL 9, forcé non interceptable, ⚠️ risque corruption), SIGHUP 1 = recharge cfg daemon. killall nom. man 7 signal. nice : -20 (haute prio) → 19 (basse). nice -n 19 cmd, renice -n 5 -p PID. Seul root baisse niceness (monte prio, valeurs négatives). Cgroups : 3 slices system/user/machine, CPU équivalent par slice, réglable CPUWeight. loginctl list-users/list-sessions, loginctl terminate-user UID.

MEMOIRE / CPU free -m/free -h, /proc/meminfo, sync (flush write cache sur disque). Linux cache bcp → RAM paraît saturée (normal). Swap = applis inactives d'abord. Load average = process en exec sur 1/5/15 min ; ne doit PAS dépasser nb de cœurs. uptime, lscpu (nb cœurs). top : f colonnes, M tri mémoire, k kill PID, W save. htop (non installé défaut). vmstat 2 25 (cols si/so = swap in/out).

SYSTEMD / SERVICES systemd = PID 1. systemctl = outil principal. Units : .service (daemon), .socket (port→service), .timer (périodique), .path (activité fichier), .mount (FS). systemctl start|stop|restart|reload <unit>, status, enable/disable (boot), enable --now (boot+start), list-units, list-unit-files. Etats : active(running), inactive(dead), enabled/disabled (boot), failed. Cfg : /usr/lib/systemd/system (paquets, NE PAS modifier), /etc/systemd/system (custom/surcharge, prio max), /run/systemd (runtime). systemctl edit <unit> (drop-in dans /etc/systemd/system), systemctl daemon-reload (après modif manuelle fichier), systemctl show. Auto-restart : [Service] Restart=always + RestartSec=5s. Dépendances : systemctl list-dependencies <unit> (service down peut = dépendance down). Masquer : systemctl mask <unit> (lien → /dev/null, impossible à démarrer) / unmask. Type=oneshot = lancer une cmd unique via systemd.

TARGETS / RUNLEVELS systemctl get-default / systemctl set-default multi-user.target (texte) | graphical.target (GUI). systemctl isolate <target> (à chaud, sans reboot). poweroff(0), rescue(1, mono-user FS local monté demande mdp root), multi-user(3, réseau SANS GUI), graphical(5), reboot(6), emergency (/ read-only rien monté). Boot sur target : menu GRUB ligne linux ajouter systemd.unit=rescue.target. 🚨 Déprécié init <n>systemctl.

LOGS / JOURNALD / RSYSLOG journald (kernel/early boot/syslog/stdout daemons, NON persistant défaut) + rsyslog (écrit /var/log). journalctl, -p err (priorité+), -f (suivi), -u sshd.service, --since "-1 hour"/--since today, -o verbose, -b (boot courant), -xb, --list-boots, -b -3 (3e boot précédent). 🚨 Persistance : mkdir /var/log/journal (le simple fait active) puis systemctl restart systemd-journald. Directive Storage= dans /etc/systemd/journald.conf : auto/persistent/volatile/none. Sans persistance → logs perdus au reboot. rsyslog : /etc/rsyslog.conf + /etc/rsyslog.d/. Règle = facility.severity destination → *.err /var/log/error.log. logger "msg" (écrit manuellement). Restart après modif. logrotate : /etc/logrotate.conf + /etc/logrotate.d/, déclenché par logrotate.timer. Directives : monthly, rotate 5, dateext, create.

DNF / RPM / REPOS RPM = archive + métadonnées (deps). rpm -qa (installés), -qf /chemin (quel paquet), -ql paquet (fichiers), -q --scripts, -q --changelog, -qp f.rpm (interroge .rpm non installé). Extraire sans installer : rpm2cpio f.rpm | cpio -idmv (récupérer 1 fichier de config supprimé). dnf install/remove (🚨 retire aussi deps orphelines, peut casser)/update, dnf update kernel (GARDE l'ancien, rollback), dnf list, dnf search all mot, dnf provides */fichier, dnf info. Groupes : dnf group list (+hidden), group info, group install "Nom" (default+mandatory), --with-optional. Historique : dnf history, dnf history undo <ID>. Log brut /var/log/dnf.rpm.log. Repos : /etc/yum.repos.d/*.repo, dnf config-manager --add-repo="file:///repo/AppStream" (3 slashes, plugin dnf-plugins-core), dnf repolist. gpgcheck=1 (vérif signature, =0 désactive). RHEL 9 = BaseOS (OS) + AppStream (applis/langages), modularité (versions multiples). Subscription : subscription-manager registerattach --autodnf repolist. Certifs : /etc/pki/{product,consumer,entitlement}.

PLANIFICATION (timers / cron / at) 3 mécanismes : systemd timers (recommandé RHEL 9), crond (historique), at (one-shot). Timers : .timer relié à .service, on gère le TIMER (enable+start). systemctl list-units --type timer, systemctl list-timers, systemctl cat <timer>. Cfg timer : [Timer] OnCalendar=*:00/10 (toutes 10 min), OnUnitActiveSec=, OnBootSec=, OnStartupSec=. man 7 systemd.time. systemctl enable <timer> pour survivre reboot. Cron : crond vérifie chaque minute. /etc/crontab (🚨 NE PAS éditer, exemples), /etc/cron.d/ (drop-in), /etc/cron.{hourly,daily,weekly,monthly}. crontab -e/-l. Format : min heure jour-mois mois jour-semaine cmd10 * * * * logger HELLO. Anacron : /etc/anacrontab, jobs daily sans heure garantie (rattrape si machine éteinte). at : systemctl status atd, at 14:00 (saisir cmd + Ctrl+D), atq (lister), atrm <n>. systemd-tmpfiles : /etc/tmpfiles.d/ (admin), /usr/lib/tmpfiles.d/ (paquets). --create/--clean. Format Type Chemin Mode User Group Aged /run/myfiles 0750 root root 1d.

DISQUES / FS / FSTAB lsblk (block devices + montages), fdisk -l /dev/sda, blkid (UUID/LABEL/TYPE), df -h, du -sh dir. Nommage : /dev/sdX (SCSI/SATA), /dev/vdX (KVM), /dev/nvme0n1p1 (NVMe). MBR : 4 primaires max, 2 TiB, au-delà → extended+logiques (1ère logique = n°5). GPT : 128 partitions, très grande taille. Créer partition (fdisk /dev/sdb) : np→numéro→Entrée→+1Gpw. t change type (linux/swap/uefi/lvm). gdisk (GPT, code 8e00 = LVM), parted (scriptable). FS : XFS (DEFAULT RHEL, augmentable PAS réductible), EXT4 (augmentable ET réductible), vfat (multi-OS), Btrfs (NON supporté RHEL). 🚨 mkfs seul = ext2 sans journal → préciser mkfs.xfs/mkfs.ext4/mkfs.vfat. Montage manuel : mount /dev/vdb1 /mnt, umount /mnt (cibler mountpoint), findmnt (arbo claire), lsof /mnt (ce qui bloque umount). 🚨 PAS de mount sans FS ni d'extended seule. fstab : <device> <mountpoint> <type> <options> <dump> <pass>/dev/sdaX /mnt ext4 defaults 0 0. dump=0, pass=0 (pas de fsck). 🚨 PIEGE CRITIQUE : erreur fstab = boot cassé → TOUJOURS mount -a + findmnt --verify AVANT reboot. systemctl daemon-reload après édition. 🚨 Montage ROBUSTE par UUID/LABEL (noms sdX changent au boot) : UUID=xxx /mnt ext4 defaults 0 0. Labels : tune2fs -L lbl /dev/sdX1 (ext), xfs_admin -L lbl (XFS), mkfs.xfs -L lbl (à la création). 🚨 Clone XFS = même UUID → conflit → xfs_admin -U generate /dev/sdb1. fstab → units .mount (ls /run/systemd/generator/). Swap : type linux-swap. mkswap /dev/sda7swaponswapoff. fstab : /dev/sda7 none swap defaults 0 0 (préférer UUID). free -m vérifie.

LVM / STRATIS Chaîne : PV (pvcreate) → VG (vgcreate) → LV (lvcreate) → FS → montage. Noms /dev/vg/lv NE changent pas → PAS besoin UUID dans fstab. A→Z : partition type lvm (fdisk t→lvm / gdisk 8e00) → pvcreate /dev/sdb1vgcreate -s 8M vgdata /dev/sdb1 (-s = taille extents) → lvcreate -L 1G -n lvdata vgdata (ou -l 255 extents) → mkfs.xfs /dev/vgdata/lvdata → fstab → mount -a. Lister : pvs/pvdisplay, vgs/vgdisplay, lvs/lvdisplay. Device mapper : /dev/dm-0 (non persistant), /dev/mapper/vgdata-lvdata + /dev/vgdata/lvdata (symlinks persistants). Etendre : vgextend vgdata /dev/sdb2 (ajouter PV) → lvextend -r -L +1G /dev/vgdata/lvdata. 🚨 -r resize AUSSI le FS. Oublié → xfs_growfs /lvdata (XFS, cible mountpoint) ou resize2fs (ext4). lvextend -r -l +50%FREE. SHRINK uniquement ext4, JAMAIS XFS. vgcreate fait pvcreate implicite. Réduire VG : pvmove -v /dev/sdf2 /dev/sdf1 (déplacer extents) → vgreduce vgdemo /dev/sdf2. Possible que si PV restants ont assez d'espace. Stratis : toujours XFS, thin provisioned, packages stratisd+stratis-cli. stratis pool create mypool /dev/sdb, pool add-data (agrandir), fs create mypool myfs/dev/stratis/mypool/myfs. 🚨 Stratis monte par UUID + option fstab x-systemd.requires=stratisd.service (sinon montage avant daemon → boot cassé). Snapshots montés par DEVICE NAME (pas UUID) : stratis fs snapshot mypool myfs myfs-snap.

RESEAU / NMCLI NetworkManager gère le réseau : connexions (profils) appliquées à devices (interfaces). Cfg dans /etc/NetworkManager/system-connections/. nmcli device status, nmcli connection show (+<con> détail), nmcli dev status. IP statique : nmcli con add type ethernet con-name X ifname ens160 ipv4.addresses 192.168.10.50/24 ipv4.gateway 192.168.10.1 ipv4.dns 8.8.8.8 ipv4.method manual. nmcli con mod X +ipv4.dns 1.1.1.1. 🚨 PIEGE : après nmcli con mod, INACTIF tant qu'on n'a pas fait nmcli con up <con> (ou con reload+up). nmtui = interface texte équivalente. ip (test/troubleshooting, VOLATILE) : ip addr (+add 10.0.0.10/24 dev ens33), ip link (+set eth0 up/down), ip -br addr, ip route (+add default via 10.0.0.1). 🚨 changements ip perdus au reboot → persistant = nmcli. Hostname : hostnamectl set-hostname server.example.com (persistant → /etc/hostname). Résolution : /etc/hosts (local statique IP→nom, prioritaire), /etc/resolv.conf (nameserver/search, géré par NM), /etc/nsswitch.conf (ordre, ligne hosts:). BIOS Device Name = ens33/enp0s3. Troubleshoot : ping -c4, ping6 ff02::1%ens33 (link-local v6 : NIC obligatoire), ip -6 route, tracepath, dig google.com. Sockets : ss -tu, ss -tuna, ss -tulpn (+PID/process). 🚨 netstatss, ifconfigip, nslookupdig.

FIREWALLD kernel netfilter → nftables (framework) → firewalld (service frontend). 🚨 iptables DEPRECIE → firewall-cmd. firewall-cmd --list-all, --get-services, --get-zones, --state. Flags : (aucun) = runtime seulement (perdu reload/reboot), --permanent = persistant MAIS pas actif runtime, --reload = charge permanent dans runtime. 🚨 PIEGE MAJEUR : ouvrir sans --permanent → perdu au reboot ; avec --permanent SANS --reload → pas actif tout de suite. METHODE SURE : firewall-cmd --permanent --add-service=http--permanent --add-port=8080/tcpfirewall-cmd --reload--list-all. Zones : public (défaut, non fiable), trusted (tout accepté), internal/home/work, dmz (exposés), block/drop (rejette/ignore). Rich rule : firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.10.0/24" service name="ssh" accept'--reload.

SSH Client détient clé PRIVEE, serveur clé PUBLIQUE. ssh-keygenssh-copy-id serverssh server (sans mdp). Passphrase → ssh-agent /bin/bash + ssh-add (cache la clé). Client : /etc/ssh/ssh_config (global) / ~/.ssh/config (user). ssh -X (X forwarding GUI distante), ssh -Y (trusted). ssh user@IP. 🚨 Serveur : /etc/ssh/sshd_config (d = daemon). NE PAS confondre ssh_config (client) vs sshd_config (serveur). Options : Port 22, PermitRootLogin no (hardening), PasswordAuthentication no, PubkeyAuthentication yes, AllowUsers u1 u2. 🚨 Après modif sshd_config → systemctl restart sshd OBLIGATOIRE. Copie : scp file user@host:/path, scp -r (récursif), sftp user@host (put/get/exit). rsync -a (archive=rlptgoD, préserve perms/liens/dates) : -n dry-run, -A +ACL, -X +contexte SELinux.

NFS / AUTOFS Client (objectif exam) : dnf install nfs-utils, showmount -e nfsserver (voir exports), mount nfsserver:/share /mnt. fstab persistant : nfsserver:/share /mnt nfs defaults,_netdev 0 0 (_netdev = attendre réseau). autofs (montage à la demande, démonte après inactivité) : dnf install autofs, systemctl enable --now autofs. /etc/auto.master : /data /etc/auto.nfsdata. Map secondaire /etc/auto.nfsdata : files -rw nfsserver:/nfsdata/data/files monte à l'accès. Wildcard homes : /etc/auto.home* -rw nfsserver:/home/ldap/& (* = nom user demandé, & = même nom serveur).

NTP / CHRONY Au boot Linux lit hardware clock → system time → (option) sync NTP. hwclock (--systohc sys→hw, --hctosys hw→sys), date. chronyd = service NTP DEFAUT RHEL 9 (PAS ntpd/ntpq, PAS systemd-timesyncd). Cfg /etc/chrony.conf : pool 2.rhel.pool.ntp.org iburst, server X iburst. systemctl restart chronyd après cfg. chronyc sources (sources+état), chronyc tracking (détail sync). timedatectl : status, set-time "2026-06-23 10:00:00", list-timezones, set-timezone Europe/Paris, set-ntp true.

SELINUX MAC (en plus du DAC). Contexte user:role:type:level ; le TYPE fait 90% (type enforcement). Source (users/process) → target (fichiers/dirs/ports) via rules de la policy. "Pas explicitement autorisé = refusé". Modes : enforcing (bloque+log), permissive (log seulement, debug), disabled. getenforce, sestatus, setenforce 0/1 (temporaire). Persistant : /etc/selinux/config SELINUX=enforcing. 🚨 RHEL 9 : disabled plus pleinement supporté → vraie désactivation = selinux=0 kernel GRUB. À l'exam : rester ENFORCING. Contextes : ls -Z, ps -Z, id -Z. 🚨 CHCON vs RESTORECON (LE piège) : chcon -t type f change à la main → ECRASE au prochain restorecon/autorelabel. BONNE méthode persistante = semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?" (déclare règle dans policy) PUIS restorecon -Rv /web (applique). TOUJOURS semanage+restorecon, jamais chcon seul. 🚨 mv conserve l'ancien contexte (pas d'héritage du dir) → accès casse → restorecon. cp hérite du dir. Booleans (interrupteurs policy) : getsebool -a, setsebool httpd_enable_homedirs on (temporaire). 🚨 setsebool -P = PERSISTANT (sans -P perdu au reboot). semanage boolean -l (desc+état), -l -C (modifiés). Ports : semanage port -l, semanage port -a -t http_port_t -p tcp 8888 (ajouter), -m (modifier). Pour port non standard OBLIGATOIRE. Troubleshoot : refus = AVC dans /var/log/audit/audit.log. grep AVC /var/log/audit/audit.log, ausearch -m AVC -ts recent, sealert -a /var/log/audit/audit.log (suggestions, paquet setroubleshoot-server), journalctl | grep sealert. 💡 marche en permissive pas en enforcing = problème SELinux. man httpd_selinux (contextes attendus), man -k _selinux. 🚨 autorelabel bloque le boot : GRUB systemd.unit=emergency.targetmount -o remount,rw /rm -f /.autorelabelrestorecon -Rv /.

GRUB / BOOT / RESCUE Séquence : firmware (BIOS/UEFI) → boot device → GRUB2 → kernel → initramfs → systemd → services. GRUB2 : presser e au démarrage pour éditer (NON persistant, 1 boot). Persistant : éditer /etc/default/grub puis grub2-mkconfig -o /boot/grub2/grub.cfg (BIOS) ou -o /boot/efi/EFI/redhat/grub.cfg (UEFI). UEFI si /boot/efi monté en vfat. 🚨 RESET MDP ROOT (rd.break) : GRUB e → ligne linux ajouter rd.break → Ctrl+x → mount -o remount,rw /sysrootchroot /sysrootpasswd roottouch /.autorelabel (SINON login root échoue, contexte /etc/shadow faux = ERREUR N°1) → exitexit. Boot target : systemd.unit=rescue.target (mdp root, FS monté) / emergency.target (/ read-only, rien monté, plus bas). Voir messages boot : retirer rhgb quiet. debug-shell : systemctl enable --now debug-shell.service → Ctrl+Alt+F9 (root sans mdp, désactiver après). Dépannage FS : mount -o remount,rw /vim /etc/fstabmount -a + findmnt --verify. xfs_repair (FS démonté), xfs_fsr/e4defrag (défrag), fsck (à froid).

PODMAN Conteneur = app + toutes deps, démarre d'une image (OCI) d'un registry. Repose sur cgroups (ressources) + namespaces (isolation) + SELinux. SANS démon, ROOTLESS possible (user non-root). Outils : podman (= docker), buildah (build images), skopeo (inspect/copy/delete/sign). dnf install container-tools. Cfg registres /etc/containers/registries.conf (+~/.config/containers/ par user). Registries : podman login registry.redhat.io, podman search ubi9, podman pull <image>, podman images, podman rmi, podman inspect. Cycle : podman run -d --name web -p 8080:80 <image> (-d détaché), podman ps (-a tous), stop/start/rm (-f forcer), podman exec -it web /bin/bash, podman logs web, podman build -t tag . (Containerfile, base UBI). Variables : -e KEY=VALUE AVANT le nom de l'image (-e MYSQL_ROOT_PASSWORD=secret). skopeo inspect docker://... voit les variables attendues. 🚨 Rootless : ports < 1024 INTERDITS → mapper sur port haut (-p 8080:80). Stockage ~/.local/share/containers. 🚨 Volumes + SELinux : bind-mount SANS suffixe :Z (privé) ou :z (partagé) → SELinux BLOQUE. :Z pose container_file_t. -v /home/user/db:/var/lib/mysql:Z. Ownership rootless : podman unshare chown 27:27 ~/mydb (namespace UID). Conteneur en service systemd (rootless) : se connecter EN TANT QUE l'user (définir mdp, PAS su -) → mkdir -p ~/.config/systemd/userpodman generate systemd --new --name web --files → copier .service → systemctl --user daemon-reloadenable --now. Vérifier WantedBy=default.target (PAS multi-user.target). Conteneur root → /etc/systemd/system. 🚨 loginctl enable-linger <user> OBLIGATOIRE (sinon conteneur s'arrête à la déconnexion, ne démarre pas au boot). generate systemd déprécié RHEL 10+ → Quadlet (~/.config/containers/systemd/*.container), mais OK pour EX200.

TUNED Profils d'optimisation système selon usage. dnf install tuned, systemctl enable --now tuned. tuned-adm list, active, profile throughput-performance, recommend. Profils : balanced, powersave, throughput-performance, virtual-guest, desktop. Cfg /etc/tuned/<profil>/tuned.conf, principal /etc/tuned/tuned-main.conf. Kernel tunables : echo 40 > /proc/sys/vm/swappiness (NON persistant). Persistant : echo "vm.swappiness=33" > /etc/sysctl.d/X.confsysctl -p /etc/sysctl.d/X.conf.

BASH SCRIPTING #!/bin/bash (shebang), key=value (PAS d'espace autour du =), $1,$2 arguments, chmod +x, ./script.sh arg, bash -x (debug). Tests [ ] : -z chaîne vide, -f fichier, -d répertoire, -gt -lt -eq -ge -le -ne (entiers), =/!= (chaînes). $(( ... )) arithmétique entière. Structures (paires) : if [ ]; then ... else ... fi, for i in ...; do ... done, while [ ]; do ... done, case ... esac, read var (saisie).

Couverture : fiches 1→7 intégrales (+ critiques de la fiche 8 récap). 1→Intro/install · 2→shell/vi/redirections/vars · 3→FHS/find/liens/tar/texte/users/sudo/SSH/perms/réseau · 4→DNF/RPM/processus/systemd/logs/cron/timers/tuned/tmpfiles · 5→disques/FS/fstab/swap/LVM/Stratis/ACL/NFS · 6→GRUB/boot/rescue/SELinux/Podman/bash · 7→nmcli/SSH/firewalld/chrony/NFS/autofs/SELinux/Podman/Kickstart.