Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:debian:10:junior:l106 [2022/04/29 16:11] – created admin | elearning:workbooks:debian:10:junior:l106 [2024/03/08 08:28] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
+ | |||
+ | Version : **2024.01** | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LDF301 | + | ======LDF501 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LDF301 | + | * **LDF501 |
* Contenu du Module | * Contenu du Module | ||
- | * Fichiers | + | * Présentation |
+ | * / | ||
+ | * Interrogation des Bases de Données | ||
+ | * Les Fichiers | ||
+ | * Les Fichiers /etc/passwd et /etc/shadow | ||
* Commandes | * Commandes | ||
- | * La Commande lspci | + | * Groupes |
- | * La Commande lsusb | + | * groupadd |
- | * La Commande dmidecode | + | * groupdel |
- | * Répertoire /proc | + | * groupmod |
- | * Répertoires | + | * newgrp |
- | * ide/scsi | + | * gpasswd |
- | * acpi | + | * Utilisateurs |
- | * bus | + | * useradd |
- | * net | + | * userdel |
- | * sys | + | * usermod |
- | * La Commande sysctl | + | * passwd |
- | * Fichiers | + | * chage |
- | * Processeur | + | * Configuration |
- | * Interruptions système | + | * LAB #1 - Gérer les Utilisateurs et les Groupes |
- | * Canaux DMA | + | * LAB #2 - Forcer |
- | * Plages d' | + | * 2.1 - Présentation |
- | * Périphériques | + | * 2.2 - Configuration |
- | * Modules | + | * 2.3 - Utiliser |
- | * Statistiques de l' | + | * LAB #3 - su et su - |
- | * Partitions | + | * LAB #4 - sudo |
- | * Espaces | + | |
- | * Statistiques d' | + | |
- | * Statistiques d' | + | |
- | * Version du noyau | + | |
- | * Interprétation | + | |
- | * Commandes | + | |
- | * free | + | |
- | * uptime ou w | + | |
- | * iostat | + | |
- | * vmstat | + | |
- | * mpstat | + | |
- | * sar | + | |
- | * Utilisation | + | |
- | * Identifier un système limité par le processeur | + | |
- | * Identifier un système ayant un problème | + | |
- | * Identifier un système ayant un problème d'E/S | + | |
- | * Modules usb | + | |
- | | + | |
- | * La Commande udevadm | + | |
- | * Système de fichiers /sys | + | |
- | * Limiter les Ressources | + | |
- | * ulimit | + | |
- | * Groupes de Contrôle | + | |
- | | + | |
- | =====Fichiers Spéciaux===== | + | =====Présentation===== |
- | + | <WRAP center round todo> | |
- | Dans l' | + | **A faire** : Afin de mettre en pratique les exemples dans ce cours, vous devez vous connecter |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** : Les périphériques qui nécessitent | + | |
</ | </ | ||
- | Consultez le contenu du répertoire /dev : | + | La bonne gestion des utilisateurs passe par une bonne stratégie de groupes. En effet, chaque utilisateur est affecté à un groupe **principal** mais il peut aussi être membre d'un ou de plusieurs groupes secondaires. |
- | < | + | Comme dans d' |
- | root@debian8: | + | |
- | total 0 | + | |
- | crw------- | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | crw------- | + | |
- | drwxr-xr-x | + | |
- | lrwxrwxrwx | + | |
- | drwxr-xr-x | + | |
- | crw------- | + | |
- | lrwxrwxrwx | + | |
- | drwxr-xr-x | + | |
- | crw------- | + | |
- | crw-rw-rw- | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | lrwxrwxrwx | + | |
- | lrwxrwxrwx | + | |
- | crw-rw-rw- | + | |
- | crw-rw-rw- | + | |
- | crw------- | + | |
- | crw------- | + | |
- | drwxr-xr-x | + | |
- | lrwxrwxrwx | + | |
- | drwxr-xr-x | + | |
- | crw-r--r-- | + | |
- | lrwxrwxrwx | + | |
- | crw-rw---- | + | |
- | drwxr-xr-x | + | |
- | crw------- | + | |
- | crw-r----- | + | |
- | drwxrwxrwt | + | |
- | --More-- | + | |
- | </ | + | |
- | On peut noter dans la sortie | + | Les bases de données utilisées pour stocker les informations des utilisateurs et des groupes |
- | < | + | * **/ |
- | ... | + | |
- | brw-rw---- | + | |
- | ... | + | |
- | crw-rw-rw- | + | |
- | ... | + | |
- | </ | + | |
- | La différence entre les deux repose sur le type de communication entre le système et le module. Dans le premier cas le système accède au périphérique par des coordonnées du bloc de données sur le support tandis que dans le deuxième cas la communication d' | + | ====/ |
- | + | ||
- | Les deux informations clefs du fichier spécial sont situées à la place de la taille d'un fichier normal et se nomment le **majeur** et le **mineur** : | + | |
- | + | ||
- | * le **majeur** identifie le pilote du périphérique et donc son contrôleur, | + | |
- | * le **mineur** identifie le périphérique ou une particularité du périphérique telle une partition d'un disque. | + | |
- | + | ||
- | =====Commandes===== | + | |
- | + | ||
- | ====La Commande lspci==== | + | |
- | + | ||
- | Cette commande vous renseigne sur les adaptateurs reliés aux bus PCI, AGP et PCI express : | + | |
< | < | ||
- | root@debian8:~# lspci | + | root@debian11:~# cat / |
- | 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) | + | # /etc/nsswitch.conf |
- | 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] | + | # |
- | 00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) | + | # Example configuration of GNU Name Service Switch functionality. |
- | 00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter | + | # If you have the `glibc-doc-reference' |
- | 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) | + | # `info libc "Name Service Switch"' |
- | 00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service | + | |
- | 00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01) | + | |
- | 00:06.0 USB controller: Apple Inc. KeyLargo/ | + | |
- | 00:07.0 Bridge: Intel Corporation 82371AB/ | + | |
- | 00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ | + | |
- | </ | + | |
- | Pour obtenir de l' | + | passwd: files systemd |
+ | group: | ||
+ | shadow: | ||
+ | gshadow: | ||
- | < | + | hosts: files mdns4_minimal |
- | root@debian8:~# lspci -v -s 00:03.0 | + | networks: files |
- | 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) | + | |
- | Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter | + | |
- | Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 10 | + | |
- | Memory at f0000000 (32-bit, non-prefetchable) | + | |
- | I/O ports at d010 [size=8] | + | |
- | Capabilities: [dc] Power Management version 2 | + | |
- | Capabilities: | + | |
- | Kernel driver in use: e1000 | + | |
- | </ | + | |
- | ou : | + | protocols: db files |
+ | services: | ||
+ | ethers: | ||
+ | rpc: db files | ||
- | < | + | netgroup: nis |
- | root@debian8:~# lspci -vv -s 00:03.0 | + | |
- | 00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02) | + | |
- | Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter | + | |
- | Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- | + | |
- | Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- | + | |
- | Latency: 64 (63750ns min) | + | |
- | Interrupt: pin A routed to IRQ 10 | + | |
- | Region 0: Memory at f0000000 (32-bit, non-prefetchable) [size=128K] | + | |
- | Region 2: I/O ports at d010 [size=8] | + | |
- | Capabilities: | + | |
- | Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0-, | + | |
- | Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME- | + | |
- | Capabilities: | + | |
- | Command: DPERE- ERO+ RBC=512 OST=1 | + | |
- | Status: Dev=ff:1f.0 64bit- 133MHz- SCD- USC- DC=simple DMMRBC=2048 DMOST=1 DMCRS=8 RSCEM- 266MHz- 533MHz- | + | |
- | Kernel driver in use: e1000 | + | |
</ | </ | ||
- | ===Options de la commande=== | + | Pour les entrées **passwd**, **group**, **shadow** et **gshadow** : |
- | Les options | + | * **files** implique l' |
+ | * **systemd** implique l' | ||
- | < | + | Il est aussi possible de trouver une autre valeur pour ces entrées |
- | root@debian8:~# lspci --help | + | |
- | lspci: invalid option -- ' | + | |
- | Usage: lspci [< | + | |
- | Basic display modes: | + | * **sss** implique l' |
- | -mm Produce machine-readable output | + | * SSSD trouve ses origines dans le projet opensource **FreeIPA** |
- | -t Show bus tree | + | * Pour plus d' |
- | Display options: | + | ====Interrogation des Bases de Données==== |
- | -v Be verbose (-vv for very verbose) | + | |
- | -k Show kernel drivers handling each device | + | |
- | -x Show hex-dump of the standard part of the config space | + | |
- | -xxx Show hex-dump of the whole config space (dangerous; root only) | + | |
- | -xxxx Show hex-dump of the 4096-byte extended config space (root only) | + | |
- | -b Bus-centric view (addresses and IRQ's as seen by the bus) | + | |
- | -D Always show domain numbers | + | |
- | Resolving of device ID's to names: | + | La commande **getent** est utilisée pour interroger les bases de données. Elle prend la forme suivante |
- | -n Show numeric ID's | + | |
- | -nn Show both textual and numeric ID's (names & numbers) | + | |
- | -q Query the PCI ID database for unknown ID's via DNS | + | |
- | -qq As above, but re-query locally cached entries | + | |
- | -Q Query the PCI ID database for all ID's via DNS | + | |
- | Selection of devices: | + | getent base-de-données clef |
- | -s [[[[< | + | |
- | -d [< | + | |
- | Other options: | + | Par exemple pour rechercher l'utilisateur dans la base de données des utilisateurs, |
- | -i < | + | |
- | -p < | + | |
- | -M Enable `bus mapping' | + | |
- | PCI access options: | + | <code> |
- | -A <method> Use the specified PCI access method (see `-A help' for a list) | + | root@debian11: |
- | -O < | + | trainee: |
- | -G Enable PCI access debugging | + | |
- | -H < | + | |
- | -F < | + | |
</ | </ | ||
- | ====La Commande lsusb==== | + | Pour rechercher quels utilisateurs appartiennent à quels groupes, il convient d' |
- | + | ||
- | Cette commande | + | |
< | < | ||
- | root@debian8:~# lsusb | + | root@debian11:~# getent group mail |
- | Bus 001 Device 004: ID 80ee:0021 VirtualBox USB Tablet | + | mail:x:8: |
- | Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub | + | |
- | + | ||
- | root@debian8: | + | |
- | /: Bus 01.Port 1: Dev 1, Class=root_hub, | + | |
- | |__ Port 1: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, | + | |
</ | </ | ||
- | ===Options | + | L' |
- | + | ||
- | Les options | + | |
< | < | ||
- | root@debian8:~# lsusb --help | + | root@debian11:~# getent passwd |
- | Usage: lsusb [options]... | + | root: |
- | List USB devices | + | daemon: |
- | -v, --verbose | + | bin: |
- | | + | sys: |
- | -s [[bus]:][devnum] | + | sync: |
- | Show only devices with specified device and/or | + | games: |
- | bus numbers (in decimal) | + | man: |
- | -d vendor:[product] | + | lp: |
- | Show only devices with the specified vendor and | + | mail: |
- | | + | news: |
- | -D device | + | uucp: |
- | | + | proxy: |
- | | + | www-data: |
- | Dump the physical USB device hierarchy as a tree | + | backup:x: |
- | -V, --version | + | list: |
- | Show version of program | + | irc: |
- | -h, --help | + | gnats: |
- | Show usage and help | + | nobody: |
+ | _apt: | ||
+ | systemd-network:x: | ||
+ | systemd-resolve: | ||
+ | messagebus: | ||
+ | systemd-timesync:x: | ||
+ | usbmux: | ||
+ | rtkit: | ||
+ | dnsmasq: | ||
+ | avahi: | ||
+ | speech-dispatcher: | ||
+ | pulse: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | sshd: | ||
</ | </ | ||
- | ====La Commande dmidecode==== | + | ====Les Fichiers /etc/group et / |
- | La commande **dmidecode** lit la table **DMI** (//Desktop Management Interface// | + | Pour lister |
- | + | ||
- | * l' | + | |
- | * les extensions possibles. | + | |
< | < | ||
- | root@debian8:~# dmidecode | + | root@debian11:~# cat /etc/group |
- | # dmidecode 2.12 | + | root:x:0: |
- | SMBIOS | + | daemon: |
- | 10 structures occupying 450 bytes. | + | bin:x:2: |
- | Table at 0x000E1000. | + | sys:x:3: |
+ | adm:x:4: | ||
+ | tty:x:5: | ||
+ | disk:x:6: | ||
+ | lp:x:7: | ||
+ | mail:x:8: | ||
+ | news:x:9: | ||
+ | uucp:x:10: | ||
+ | man:x:12: | ||
+ | proxy: | ||
+ | kmem: | ||
+ | dialout: | ||
+ | fax:x:21: | ||
+ | voice: | ||
+ | cdrom: | ||
+ | floppy: | ||
+ | tape: | ||
+ | sudo: | ||
+ | audio: | ||
+ | dip: | ||
+ | www-data: | ||
+ | backup: | ||
+ | operator: | ||
+ | list: | ||
+ | irc:x:39: | ||
+ | src:x:40: | ||
+ | gnats: | ||
+ | shadow: | ||
+ | utmp: | ||
+ | video: | ||
+ | sasl: | ||
+ | plugdev: | ||
+ | staff: | ||
+ | games: | ||
+ | users: | ||
+ | nogroup: | ||
+ | systemd-journal: | ||
+ | systemd-network: | ||
+ | systemd-resolve: | ||
+ | input: | ||
+ | kvm: | ||
+ | render: | ||
+ | crontab: | ||
+ | netdev: | ||
+ | messagebus: | ||
+ | systemd-timesync: | ||
+ | ssh: | ||
+ | ssl-cert: | ||
+ | rtkit: | ||
+ | avahi: | ||
+ | lpadmin: | ||
+ | pulse: | ||
+ | pulse-access: | ||
+ | scanner: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | mlocate: | ||
+ | </ | ||
- | Handle 0x0000, DMI type 0, 20 bytes | + | <WRAP center round important> |
- | BIOS Information | + | **Important** : Notez que la valeur du GID du groupe root est toujours de 0. Notez que sous Debian 11, les GID des utilisateurs normaux commencent à **1000** et les GID des comptes système sont inclus entre 1 et 99 et entre 201 et 999. |
- | Vendor: innotek GmbH | + | </WRAP> |
- | Version: VirtualBox | + | |
- | Release Date: 12/01/2006 | + | |
- | Address: 0xE0000 | + | |
- | Runtime Size: 128 kB | + | |
- | ROM Size: 128 kB | + | |
- | Characteristics: | + | |
- | ISA is supported | + | |
- | PCI is supported | + | |
- | Boot from CD is supported | + | |
- | Selectable boot is supported | + | |
- | 8042 keyboard services are supported (int 9h) | + | |
- | CGA/mono video services are supported (int 10h) | + | |
- | ACPI is supported | + | |
- | Handle 0x0001, DMI type 1, 27 bytes | + | Dans ce fichier, chaque ligne est constituée de 4 champs |
- | System Information | + | |
- | Manufacturer: | + | |
- | Product Name: VirtualBox | + | |
- | Version: 1.2 | + | |
- | Serial Number: 0 | + | |
- | UUID: 3AEF2B0F-3420-4DF3-A98F-211C945D7CCA | + | |
- | Wake-up Type: Power Switch | + | |
- | SKU Number: Not Specified | + | |
- | Family: Virtual Machine | + | |
- | Handle 0x0008, DMI type 2, 15 bytes | + | * Le nom **unique** du groupe, |
- | Base Board Information | + | * Le mot de passe du groupe. Une valeur de **x** dans ce champs indique que le système utilise le fichier **/ |
- | Manufacturer: | + | * Le GID. Une valeur unique utilisée pour déterminée les droits d' |
- | Product Name: VirtualBox | + | * La liste des membres ayant le groupe comme groupe **secondaire**. |
- | Version: 1.2 | + | |
- | Serial Number: 0 | + | |
- | Asset Tag: Not Specified | + | |
- | Features: | + | |
- | Board is a hosting board | + | |
- | Location In Chassis: Not Specified | + | |
- | Chassis Handle: 0x0003 | + | |
- | Type: Motherboard | + | |
- | Contained Object Handles: 0 | + | |
- | Handle 0x0003, DMI type 3, 13 bytes | + | Pour consulter le fichier **/ |
- | Chassis Information | + | |
- | Manufacturer: | + | |
- | Type: Other | + | |
- | Lock: Not Present | + | |
- | Version: Not Specified | + | |
- | Serial Number: Not Specified | + | |
- | Asset Tag: Not Specified | + | |
- | Boot-up State: Safe | + | |
- | Power Supply State: Safe | + | |
- | Thermal State: Safe | + | |
- | Security Status: None | + | |
- | Handle 0x0007, DMI type 126, 42 bytes | + | < |
- | Inactive | + | root@debian11: |
- | + | root:*:: | |
- | Handle 0x0005, DMI type 126, 15 bytes | + | daemon:*:: |
- | Inactive | + | bin:*:: |
- | + | sys:*:: | |
- | Handle 0x0006, DMI type 126, 28 bytes | + | adm:*:: |
- | Inactive | + | tty:*:: |
- | + | disk:*:: | |
- | Handle 0x0002, DMI type 11, 7 bytes | + | lp:*:: |
- | OEM Strings | + | mail:*:: |
- | String 1: vboxVer_4.3.28 | + | news:*:: |
- | String 2: vboxRev_100309 | + | uucp:*:: |
- | + | man:*:: | |
- | Handle 0x0008, DMI type 128, 8 bytes | + | proxy:*:: |
- | OEM-specific Type | + | kmem:*:: |
- | Header and Data: | + | dialout: |
- | 80 08 08 00 F2 13 21 00 | + | fax:*:: |
- | + | voice:*:: | |
- | Handle 0xFEFF, DMI type 127, 4 bytes | + | cdrom: |
- | End Of Table | + | floppy: |
+ | tape:*:: | ||
+ | sudo:*:: | ||
+ | audio: | ||
+ | dip: | ||
+ | www-data:*:: | ||
+ | backup:*:: | ||
+ | operator: | ||
+ | list:*:: | ||
+ | irc:*:: | ||
+ | src:*:: | ||
+ | gnats:*:: | ||
+ | shadow: | ||
+ | utmp:*:: | ||
+ | video: | ||
+ | sasl:*:: | ||
+ | plugdev: | ||
+ | staff:*:: | ||
+ | games:*:: | ||
+ | users:*:: | ||
+ | nogroup: | ||
+ | systemd-journal: | ||
+ | systemd-network: | ||
+ | systemd-resolve: | ||
+ | input:!:: | ||
+ | kvm:!:: | ||
+ | render: | ||
+ | crontab: | ||
+ | netdev: | ||
+ | messagebus: | ||
+ | systemd-timesync: | ||
+ | ssh:!:: | ||
+ | ssl-cert: | ||
+ | rtkit:!:: | ||
+ | avahi:!:: | ||
+ | lpadmin: | ||
+ | pulse:!:: | ||
+ | pulse-access: | ||
+ | scanner: | ||
+ | saned:!:: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | mlocate:!:: | ||
</ | </ | ||
- | ===Options | + | Chaque ligne est constituée |
- | Les options | + | * Le nom du groupe. Ce champs est utilisé pour faire le lien avec le fichier **/ |
+ | * Le mot de passe **crypté** du groupe s'il en existe un. Une valeur **vide** dans ce champs indique que seuls les membres du groupe peuvent exécuter la commande | ||
+ | * L' | ||
+ | * La liste des membres ayant le groupe comme groupe **secondaire**. | ||
- | < | + | Afin de vérifier les fichiers **/etc/group** et **/etc/gshadow** pour des erreurs éventuelles, |
- | root@debian8: | + | |
- | Usage: dmidecode [OPTIONS] | + | |
- | Options are: | + | |
- | -d, --dev-mem FILE Read memory from device FILE (default: | + | |
- | -h, --help | + | |
- | -q, --quiet | + | |
- | -s, --string KEYWORD | + | |
- | -t, --type TYPE Only display the entries of given type | + | |
- | -u, --dump | + | |
- | | + | |
- | | + | |
- | -V, --version | + | |
- | </code> | + | |
- | + | ||
- | =====Répertoire | + | |
- | + | ||
- | Le répertoire /proc contient | + | |
< | < | ||
- | root@debian8:~# ls /proc | + | root@debian11:~# grpck -r |
- | 1 | + | root@debian11: |
- | 10 1104 124 | + | |
- | 1013 1106 1240 19 32 | + | |
- | 1014 1108 125 | + | |
- | 1023 1117 1251 20 424 | + | |
- | 1024 1120 1277 21 434 | + | |
- | 1028 1127 1288 2180 439 | + | |
- | 1029 1131 1294 2284 441 | + | |
- | 1032 1135 13 23 448 | + | |
- | 1033 1139 14 2305 450 | + | |
- | 1040 1140 1409 2306 452 | + | |
- | 1043 1142 15 232 457 | + | |
- | 1045 1156 1572 236 460 | + | |
- | 1049 1163 158 | + | |
- | 1053 1165 16 2599 464 | + | |
- | 1056 1166 163 | + | |
- | 1065 1171 1682 2635 472 | + | |
- | 1080 1177 1685 2737 497 | + | |
- | 1081 12 1687 2772 498 | + | |
- | 1084 1216 1693 2811 5 | + | |
- | 1092 1228 1694 2834 66 | + | |
- | 11 1230 17 3 67 | + | |
</ | </ | ||
- | ====Répertoires==== | + | Dans le cas où vos fichiers ne comportent pas d' |
- | ===ide/scsi=== | + | <WRAP center round important> |
+ | **Important** : L' | ||
+ | </WRAP> | ||
- | Ce répertoire contient | + | Dans le cas où il est nécessaire de régénérer un des deux fichiers, il convient d' |
- | ===acpi=== | + | * **grpconv** |
+ | * permet de régénérer le fichier **/ | ||
+ | * **grpunconv** | ||
+ | * permet de régénérer le fichier **/ | ||
- | Ce répertoire contient des informations sur la gestion de l' | + | ====Les Fichiers /etc/passwd et / |
- | ===bus=== | + | <WRAP center round important> |
+ | **Important** : Notez que la règle la plus libérale concernant les noms d' | ||
+ | </ | ||
- | Ce répertoire contient un sous-répertoire par bus. | + | Pour lister les comptes utilisateur existants sur le système, saisissez la commande suivante : |
- | ===net=== | + | < |
+ | root@debian11: | ||
+ | root: | ||
+ | daemon: | ||
+ | bin: | ||
+ | sys: | ||
+ | sync: | ||
+ | games: | ||
+ | man: | ||
+ | lp: | ||
+ | mail: | ||
+ | news: | ||
+ | uucp: | ||
+ | proxy: | ||
+ | www-data: | ||
+ | backup: | ||
+ | list: | ||
+ | irc: | ||
+ | gnats: | ||
+ | nobody: | ||
+ | _apt: | ||
+ | systemd-network: | ||
+ | systemd-resolve: | ||
+ | messagebus: | ||
+ | systemd-timesync: | ||
+ | usbmux: | ||
+ | rtkit: | ||
+ | dnsmasq: | ||
+ | avahi: | ||
+ | speech-dispatcher: | ||
+ | pulse: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | sshd: | ||
+ | </ | ||
- | Ce répertoire contient | + | <WRAP center round important> |
+ | **Important** : Notez que la valeur de l'UID de root est toujours de 0. Notez que sous Debian 11, les UID des utilisateurs normaux commencent à **1000** et les UID des comptes système sont inclus entre 1 et 99 et entre 201 et 999. | ||
+ | </ | ||
- | ===sys=== | + | Chaque ligne est constituée de 7 champs : |
- | Ce répertoire contient des paramètres du noyau. Certains des fichiers | + | * Le nom d' |
+ | * Le mot de passe. Une valeur de **x** dans ce champs indique que le système utilise le fichier **/ | ||
+ | * L'UID. Une valeur unique qui est utilisée | ||
+ | | ||
+ | | ||
+ | * Le répertoire personnel de l' | ||
+ | * Le shell de l' | ||
- | # echo 1 > /proc/sys/ | + | Pour consulter le fichier **/etc/shadow**, saisissez la commande suivante : |
- | Cette commande a pour résultat d' | + | < |
+ | root@debian11: | ||
+ | root: | ||
+ | daemon: | ||
+ | bin: | ||
+ | sys: | ||
+ | sync: | ||
+ | games: | ||
+ | man: | ||
+ | lp: | ||
+ | mail: | ||
+ | news: | ||
+ | uucp: | ||
+ | proxy: | ||
+ | www-data: | ||
+ | backup: | ||
+ | list: | ||
+ | irc: | ||
+ | gnats: | ||
+ | nobody: | ||
+ | _apt: | ||
+ | systemd-network: | ||
+ | systemd-resolve: | ||
+ | messagebus: | ||
+ | systemd-timesync: | ||
+ | usbmux: | ||
+ | rtkit: | ||
+ | dnsmasq: | ||
+ | avahi: | ||
+ | speech-dispatcher: | ||
+ | pulse: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | sshd: | ||
+ | </ | ||
- | ===La commande sysctl=== | + | Chaque ligne est constituée de 8 champs : |
- | Les fichiers dans le répertoire | + | * Le nom de l' |
+ | * Le mot de passe **crypté** de l' | ||
+ | * **!!** - Le mot de passe n'a pas encore été défini et l' | ||
+ | * ***** - L' | ||
+ | * **vide** - aucun mot de passe sera demandé pour l' | ||
+ | * Le nombre de jours entre le **01/ | ||
+ | * Le nombre de jours que le mot de passe est encore valide. Une valeur de **0** dans ce champs indique sue le mot de passe n' | ||
+ | * Le nombre de jours après lequel le mot de passe doit être changé, | ||
+ | * Le nombre de jours avant la date de modification forcée que l' | ||
+ | | ||
+ | | ||
- | La commande | + | Afin de vérifier les fichiers |
- | + | ||
- | Saisissez | + | |
< | < | ||
- | root@debian8:~# cat /etc/sysctl.conf | + | root@debian11:~# pwck -r |
- | # | + | user ' |
- | # /etc/sysctl.conf | + | user ' |
- | # See /etc/sysctl.d/ for additional system variables. | + | user ' |
- | # See sysctl.conf (5) for information. | + | user 'www-data': directory '/ |
- | # | + | user ' |
+ | user ' | ||
+ | user ' | ||
+ | user ' | ||
+ | user ' | ||
+ | pwck: no changes | ||
+ | </ | ||
- | #kernel.domainname = example.com | + | <WRAP center round important> |
+ | **Important** : Les erreurs ci-dessus ne sont pas importantes. Elles sont dues au fait que les répertoires de connexion de certains comptes systèmes ne sont pas créés par le système lors de la création des comptes et ceci justement pour éviter la possibilité qu'un pirate ou un hacker puisse se connecter au système en utilisant le compte concerné. Encore une fois, l' | ||
+ | </ | ||
- | # Uncomment the following to stop low-level messages on console | + | Dans le cas où il est nécessaire de régénérer un des deux fichiers, il convient d' |
- | # | + | |
- | ############################################################## | + | * **pwconv** |
- | # Functions previously found in netbase | + | * permet de régénérer le fichier **/ |
- | # | + | * **pwunconv** |
+ | * permet de régénérer le fichier **/ | ||
- | # Uncomment the next two lines to enable Spoof protection (reverse-path filter) | ||
- | # Turn on Source Address Verification in all interfaces to | ||
- | # prevent some spoofing attacks | ||
- | # | ||
- | # | ||
- | # Uncomment the next line to enable TCP/IP SYN cookies | + | =====Commandes===== |
- | # See http:// | + | |
- | # Note: This may impact IPv6 TCP sessions too | + | |
- | # | + | |
- | # Uncomment the next line to enable packet forwarding for IPv4 | + | ====Groupes==== |
- | # | + | |
- | # Uncomment the next line to enable packet forwarding for IPv6 | + | ===groupadd=== |
- | # Enabling this option disables Stateless Address Autoconfiguration | + | |
- | # based on Router Advertisements for this host | + | |
- | # | + | |
+ | Cette commande est utilisée pour créer un groupe. | ||
- | ################################################################### | + | Les options de cette commande sont : |
- | # Additional settings - these settings can improve the network | + | |
- | # security of the host and prevent against some network attacks | + | |
- | # including spoofing attacks and man in the middle attacks through | + | |
- | # redirection. Some network environments, | + | |
- | # settings are disabled so review and enable them as needed. | + | |
- | # | + | |
- | # Do not accept ICMP redirects (prevent MITM attacks) | + | |
- | # | + | |
- | # | + | |
- | # _or_ | + | |
- | # Accept ICMP redirects only for gateways listed in our default | + | |
- | # gateway list (enabled by default) | + | |
- | # net.ipv4.conf.all.secure_redirects = 1 | + | |
- | # | + | |
- | # Do not send ICMP redirects (we are not a router) | + | |
- | # | + | |
- | # | + | |
- | # Do not accept IP source route packets (we are not a router) | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # Log Martian Packets | + | |
- | # | + | |
- | # | + | |
- | </ | + | |
- | + | ||
- | ==Options de la commande== | + | |
- | + | ||
- | Les options de la commande | + | |
< | < | ||
- | root@debian8:~# sysctl | + | root@debian11:~# groupadd |
- | + | Usage: | |
- | Usage: | + | |
- | | + | |
Options: | Options: | ||
- | -a, --all display all variables | + | -f, --force |
- | -A | + | and cancel |
- | -X alias of -a | + | -g, --gid GID use GID for the new group |
- | --deprecated | + | -h, --help display this help message and exit |
- | -b, --binary | + | -K, --key KEY=VALUE |
- | -e, --ignore | + | -o, --non-unique |
- | -N, --names print variable names without values | + | (non-unique) GID |
- | -n, --values | + | -p, --password PASSWORD |
- | -p, --load[=< | + | -r, --system |
- | | + | -R, --root CHROOT_DIR |
- | | + | -P, --prefix PREFIX_DIR |
- | -r, --pattern < | + | |
- | | + | |
- | -q, --quiet do not echo variable set | + | |
- | -w, --write | + | |
- | -o does nothing | + | |
- | -x does nothing | + | |
- | -d alias of -h | + | |
- | + | ||
- | -h, --help | + | |
- | -V, --version | + | |
- | + | ||
- | For more details see sysctl(8). | + | |
</ | </ | ||
<WRAP center round important> | <WRAP center round important> | ||
- | **Important** : Consultez la page de la traduction du manuel de **sysctl** **[[http:// | + | **Important** : Il est possible |
</ | </ | ||
- | ====Fichiers==== | + | <WRAP center round important> |
+ | **Important** : Notez l' | ||
+ | </ | ||
- | ===Processeur=== | + | ===groupdel=== |
- | < | + | Cette commande est utilisée pour supprimer un groupe. |
- | root@debian8: | + | |
- | processor : 0 | + | |
- | vendor_id : GenuineIntel | + | |
- | cpu family : 6 | + | |
- | model : 55 | + | |
- | model name : Intel(R) Celeron(R) CPU N2840 @ 2.16GHz | + | |
- | stepping : 8 | + | |
- | microcode : 0x19 | + | |
- | cpu MHz : 2167.709 | + | |
- | cache size : 6144 KB | + | |
- | physical id : 0 | + | |
- | siblings : 1 | + | |
- | core id : 0 | + | |
- | cpu cores : 1 | + | |
- | apicid : 0 | + | |
- | initial apicid : 0 | + | |
- | fdiv_bug : no | + | |
- | f00f_bug : no | + | |
- | coma_bug : no | + | |
- | fpu : yes | + | |
- | fpu_exception : | + | |
- | cpuid level : 5 | + | |
- | wp : yes | + | |
- | flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 nx rdtscp constant_tsc pni monitor ssse3 | + | |
- | bogomips : 4335.41 | + | |
- | clflush size : 64 | + | |
- | cache_alignment : | + | |
- | address sizes : 36 bits physical, 48 bits virtual | + | |
- | power management: | + | |
- | </ | + | |
- | ===Interruptions système=== | + | Les options de cette commande sont : |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# groupdel |
- | | + | Usage: groupdel [options] GROUP |
- | 0: | + | |
- | 1: | + | |
- | 2: 0 XT-PIC-XT-PIC | + | |
- | 8: 0 XT-PIC-XT-PIC | + | |
- | 9: 83729 XT-PIC-XT-PIC | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | NMI: 0 | + | |
- | LOC: | + | |
- | SPU: 0 | + | |
- | PMI: 0 | + | |
- | IWI: 0 IRQ work interrupts | + | |
- | RTR: 0 APIC ICR read retries | + | |
- | RES: 0 | + | |
- | CAL: 0 | + | |
- | TLB: 0 TLB shootdowns | + | |
- | TRM: 0 | + | |
- | THR: 0 | + | |
- | MCE: 0 | + | |
- | MCP: | + | |
- | HYP: 0 | + | |
- | ERR: 0 | + | |
- | MIS: 0 | + | |
- | </ | + | |
- | <WRAP center round important> | + | Options: |
- | **Important** : Un pilote de périphérique demande au processeur de fournir un service en utilisant un IRQ. Quand la demande est faite, le processeur interrompe ses activités et passe le contrôle au pilote identifié par l'IRQ. Techniquement l' | + | -h, --help |
- | </WRAP> | + | -R, --root CHROOT_DIR |
- | + | -P, --prefix PREFIX_DIR | |
- | ===Canaux DMA=== | + | -f, --force |
- | + | ||
- | < | + | |
- | root@debian8: | + | |
- | 4: cascade | + | |
</ | </ | ||
- | ===Plages d' | + | ===groupmod=== |
- | < | + | Cette commande est utilisée pour modifier un groupe existant. |
- | root@debian8: | + | |
- | 0000-001f : dma1 | + | |
- | 0020-0021 : pic1 | + | |
- | 0040-0043 : timer0 | + | |
- | 0050-0053 : timer1 | + | |
- | 0060-0060 : keyboard | + | |
- | 0064-0064 : keyboard | + | |
- | 0070-0071 : rtc_cmos | + | |
- | 0070-0071 : rtc0 | + | |
- | 0080-008f : dma page reg | + | |
- | 00a0-00a1 : pic2 | + | |
- | 00c0-00df : dma2 | + | |
- | 00f0-00ff : fpu | + | |
- | 0170-0177 : 0000:00:01.1 | + | |
- | 0170-0177 : ata_piix | + | |
- | 01f0-01f7 : 0000: | + | |
- | 01f0-01f7 : ata_piix | + | |
- | 0376-0376 : 0000: | + | |
- | 0376-0376 : ata_piix | + | |
- | 03c0-03df : vga+ | + | |
- | 03f6-03f6 : 0000: | + | |
- | 03f6-03f6 : ata_piix | + | |
- | 0cf8-0cff : PCI conf1 | + | |
- | 4000-4003 : ACPI PM1a_EVT_BLK | + | |
- | --More-- | + | |
- | </ | + | |
- | <WRAP center round alert> | + | Les options de cette commande sont : |
- | Si deux périphériques ont le même port, les **deux** périphériques seront inutilisables. | + | |
- | </ | + | |
- | + | ||
- | ===Périphériques=== | + | |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# groupmod --help |
- | Character devices: | + | Usage: groupmod [options] GROUP |
- | 1 mem | + | |
- | 4 /dev/vc/0 | + | |
- | 4 tty | + | |
- | 4 ttyS | + | |
- | 5 /dev/tty | + | |
- | 5 / | + | |
- | 5 /dev/ptmx | + | |
- | 6 lp | + | |
- | 7 vcs | + | |
- | 10 misc | + | |
- | 13 input | + | |
- | 21 sg | + | |
- | 29 fb | + | |
- | 99 ppdev | + | |
- | 116 alsa | + | |
- | 128 ptm | + | |
- | 136 pts | + | |
- | 180 usb | + | |
- | 189 usb_device | + | |
- | 226 drm | + | |
- | 251 hidraw | + | |
- | 252 bsg | + | |
- | 253 watchdog | + | |
- | 254 rtc | + | |
- | Block devices: | + | Options: |
- | 259 blkext | + | -g, --gid GID |
- | | + | |
- | 11 sr | + | -n, --new-name NEW_GROUP |
- | 65 sd | + | -o, --non-unique |
- | 66 sd | + | -p, --password PASSWORD |
- | 67 sd | + | |
- | 68 sd | + | -R, --root CHROOT_DIR |
- | 69 sd | + | -P, --prefix PREFIX_DIR |
- | 70 sd | + | |
- | 71 sd | + | |
- | 128 sd | + | |
- | 129 sd | + | |
- | 130 sd | + | |
- | 131 sd | + | |
- | 132 sd | + | |
- | 133 sd | + | |
- | 134 sd | + | |
- | 135 sd | + | |
</ | </ | ||
- | ===Modules=== | + | ===newgrp=== |
- | < | + | Cette commande est utilisée pour modifier le groupe de l' |
- | root@debian8: | + | |
- | cfg80211 350041 0 - Live 0xf9426000 | + | |
- | rfkill 18387 1 cfg80211, Live 0xf92ae000 | + | |
- | vboxsf 36590 0 - Live 0xf81f1000 (O) | + | |
- | nfsd 236959 2 - Live 0xf9360000 | + | |
- | auth_rpcgss 45765 1 nfsd, Live 0xf81e4000 | + | |
- | oid_registry 12387 1 auth_rpcgss, | + | |
- | nfs_acl 12463 1 nfsd, Live 0xf7ff7000 | + | |
- | nfs 168022 0 - Live 0xf9335000 | + | |
- | lockd 73443 2 nfsd,nfs, Live 0xf8137000 | + | |
- | fscache 44782 1 nfs, Live 0xf8096000 | + | |
- | sunrpc 211341 6 nfsd, | + | |
- | joydev 16847 0 - Live 0xf8193000 | + | |
- | snd_intel8x0 30521 2 - Live 0xf812e000 | + | |
- | snd_ac97_codec 96151 1 snd_intel8x0, | + | |
- | snd_pcm 78128 2 snd_intel8x0, | + | |
- | snd_timer 22010 1 snd_pcm, Live 0xf808f000 | + | |
- | snd 55101 8 snd_intel8x0, | + | |
- | soundcore 12890 1 snd, Live 0xf8069000 | + | |
- | ac97_bus 12462 1 snd_ac97_codec, | + | |
- | vboxvideo 12405 1 - Live 0xf8055000 (O) | + | |
- | pcspkr 12531 0 - Live 0xf7e1b000 | + | |
- | drm 203555 3 vboxvideo, Live 0xf9202000 | + | |
- | psmouse 93505 0 - Live 0xf8077000 | + | |
- | --More-- | + | |
- | </ | + | |
- | ===Statistiques | + | Les options |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# newgrp --help |
- | 8 0 sda 18987 11031 1082886 269752 13611 11447 380664 169532 0 123708 438044 | + | Usage: newgrp [-] [group] |
- | | + | |
- | | + | |
- | | + | |
- | 11 0 sr0 0 0 0 0 0 0 0 0 0 0 0 | + | |
</ | </ | ||
- | ===Partitions=== | + | ===gpasswd=== |
- | < | + | Cette commande est utilisée pour administrer le fichier **/etc/group**. |
- | root@debian8: | + | |
- | major minor # | + | |
- | | + | Les options |
- | | + | |
- | | + | |
- | | + | |
- | 11 0 1048575 sr0 | + | |
- | </ | + | |
- | + | ||
- | ===Espaces | + | |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# gpasswd |
- | Filename Type Size Used Priority | + | Usage: gpasswd [option] GROUP |
- | / | + | |
- | </ | + | |
- | ===Statistiques d' | + | Options: |
- | + | -a, --add USER add USER to GROUP | |
- | < | + | -d, --delete USER |
- | root@debian8:~# cat / | + | -h, --help |
- | 0.77 0.80 0.76 2/290 2984 | + | -Q, --root CHROOT_DIR |
+ | -r, --remove-password | ||
+ | -R, --restrict | ||
+ | -M, --members USER,... set the list of members of GROUP | ||
+ | -A, --administrators ADMIN,... | ||
+ | set the list of administrators for GROUP | ||
+ | Except for the -A and -M options, the options cannot be combined. | ||
</ | </ | ||
- | ===Statistiques d' | + | ====Utilisateurs==== |
- | < | + | ===useradd=== |
- | root@debian8: | + | |
- | MemTotal: | + | |
- | MemFree: | + | |
- | MemAvailable: | + | |
- | Buffers: | + | |
- | Cached: | + | |
- | SwapCached: | + | |
- | Active: | + | |
- | Inactive: | + | |
- | Active(anon): | + | |
- | Inactive(anon): | + | |
- | Active(file): | + | |
- | Inactive(file): | + | |
- | Unevictable: | + | |
- | Mlocked: | + | |
- | HighTotal: | + | |
- | HighFree: | + | |
- | LowTotal: | + | |
- | LowFree: | + | |
- | SwapTotal: | + | |
- | SwapFree: | + | |
- | Dirty: | + | |
- | Writeback: | + | |
- | AnonPages: | + | |
- | Mapped: | + | |
- | Shmem: | + | |
- | Slab: 36092 kB | + | |
- | SReclaimable: | + | |
- | SUnreclaim: | + | |
- | KernelStack: | + | |
- | PageTables: | + | |
- | NFS_Unstable: | + | |
- | Bounce: | + | |
- | WritebackTmp: | + | |
- | CommitLimit: | + | |
- | Committed_AS: | + | |
- | VmallocTotal: | + | |
- | VmallocUsed: | + | |
- | VmallocChunk: | + | |
- | HardwareCorrupted: | + | |
- | AnonHugePages: | + | |
- | HugePages_Total: | + | |
- | HugePages_Free: | + | |
- | HugePages_Rsvd: | + | |
- | HugePages_Surp: | + | |
- | Hugepagesize: | + | |
- | DirectMap4k: | + | |
- | DirectMap2M: | + | |
- | </ | + | |
- | ===Version du noyau=== | + | Cette commande est utilisée pour ajouter un utilisateur. |
- | < | + | Les codes retour de la commande useradd sont : |
- | root@debian8:~# cat / | + | |
- | Linux version 3.16.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.7-ckt11-1+deb8u5 (2015-10-09) | + | |
- | </ | + | |
- | ==== Interprétation des informations dans /proc==== | + | ^ Code Retour ^ Description ^ |
+ | | 1 | Impossible de mettre à jour le fichier | ||
+ | | 2 | Syntaxe invalide | | ||
+ | | 3 | Option invalide | | ||
+ | | 4 | L'UID demandé est déjà utilisé | | ||
+ | | 6 | Le groupe spécifié n' | ||
+ | | 9 | Le nom d' | ||
+ | | 10 | Impossible de mettre à jour le fichier / | ||
+ | | 12 | Impossible de créer le répertoire personnel de l' | ||
+ | | 13 | Impossible de créer le spool mail de l' | ||
- | Les informations brutes stockées dans /proc peuvent être interprétées grâce à l' | + | Les options |
- | + | ||
- | * free, | + | |
- | * uptime et w, | + | |
- | * iostat, | + | |
- | * vmstat, | + | |
- | * mpstat, | + | |
- | * sar. | + | |
- | + | ||
- | ===Commandes=== | + | |
- | + | ||
- | ==free== | + | |
- | + | ||
- | La commande | + | |
< | < | ||
- | root@debian8:~# free -m | + | root@debian11:~# useradd |
- | total | + | Usage: useradd [options] LOGIN |
- | Mem: | + | useradd -D |
- | -/+ buffers/cache: | + | |
- | Swap: | + | |
+ | Options: | ||
+ | --badnames | ||
+ | -b, --base-dir BASE_DIR | ||
+ | new account | ||
+ | --btrfs-subvolume-home | ||
+ | -c, --comment COMMENT | ||
+ | -d, --home-dir HOME_DIR | ||
+ | -D, --defaults | ||
+ | -e, --expiredate EXPIRE_DATE | ||
+ | -f, --inactive INACTIVE | ||
+ | -g, --gid GROUP name or ID of the primary group of the new | ||
+ | account | ||
+ | -G, --groups GROUPS | ||
+ | account | ||
+ | -h, --help | ||
+ | -k, --skel SKEL_DIR | ||
+ | -K, --key KEY=VALUE | ||
+ | -l, --no-log-init | ||
+ | faillog databases | ||
+ | -m, --create-home | ||
+ | -M, --no-create-home | ||
+ | -N, --no-user-group | ||
+ | the user | ||
+ | -o, --non-unique | ||
+ | (non-unique) UID | ||
+ | -p, --password PASSWORD | ||
+ | -r, --system | ||
+ | -R, --root CHROOT_DIR | ||
+ | -P, --prefix PREFIX_DIR | ||
+ | -s, --shell SHELL login shell of the new account | ||
+ | -u, --uid UID user ID of the new account | ||
+ | -U, --user-group | ||
+ | -Z, --selinux-user SEUSER | ||
</ | </ | ||
- | Dans le cas de ce dernier exemple, nous pouvons constater que l’affichage montre | + | <WRAP center round important> |
+ | **Important** | ||
+ | </ | ||
- | * 1007 Mo de mémoire physique totale, | + | <WRAP center round important> |
- | * 930 Mo de mémoire physique utilisée et 76 Mo de mémoire physique libre, | + | **Important** : Notez l' |
- | | + | </ |
- | La ligne **-/+ buffers/ | + | ===userdel=== |
+ | |||
+ | Cette commande est utilisée pour supprimer un utilisateur. | ||
Les options de cette commande sont : | Les options de cette commande sont : | ||
< | < | ||
- | root@debian8:~# free --help | + | root@debian11:~# userdel |
- | + | Usage: | |
- | Usage: | + | |
- | | + | |
Options: | Options: | ||
- | -b, --bytes show output in bytes | + | |
- | -k, --kilo | + | even if not owned by user |
- | -m, --mega show output in megabytes | + | |
- | -g, --giga show output in gigabytes | + | -r, --remove |
- | | + | -R, --root CHROOT_DIR |
- | -h, --human | + | -P, --prefix PREFIX_DIR |
- | | + | -Z, --selinux-user |
- | -l, --lohi show detailed low and high memory statistics | + | </ |
- | -o, --old use old format (without -/+buffers/cache line) | + | |
- | -t, --total show total for RAM + swap | + | |
- | -s N, --seconds N | + | |
- | -c N, --count N | + | |
- | | + | <WRAP center round important> |
- | -V, --version | + | **Important** : Notez que lors de la suppression d'un utilisateur, l'UID associé avec ce compte peut être réutilisé. Le nombre maximum de comptes était de **65 536** avec le noyau **2.2.x**. Avec les noyaux récents, cette limite passe à plus de 4,2 Milliards. |
+ | </ | ||
- | For more details see free(1). | + | ===usermod=== |
- | </ | + | |
- | ==uptime ou w== | + | Cette commande est utilisée pour modifier un utilisateur existant. |
- | Chacune des ces commandes indique la charge moyenne du ou des processeurs depuis 1 minute, 5 minutes et 15 minutes | + | Les options de cette commande sont : |
< | < | ||
- | root@debian8:~# uptime | + | root@debian11:~# usermod --help |
- | 09:37:06 up 2:31, 3 users, | + | Usage: usermod [options] LOGIN |
- | root@debian8:~# w | + | Options: |
- | 09:37:08 up 2:31, | + | |
- | USER | + | -c, --comment COMMENT |
- | trainee | + | -d, --home HOME_DIR |
- | trainee | + | -e, --expiredate EXPIRE_DATE |
- | trainee | + | |
+ | to INACTIVE | ||
+ | -g, --gid GROUP | ||
+ | -G, --groups GROUPS | ||
+ | | ||
+ | mentioned by the -G option without removing | ||
+ | the user from other groups | ||
+ | -h, --help display this help message and exit | ||
+ | | ||
+ | -L, --lock | ||
+ | -m, --move-home | ||
+ | new location (use only with -d) | ||
+ | -o, --non-unique | ||
+ | -p, --password PASSWORD | ||
+ | -R, --root CHROOT_DIR | ||
+ | -P, --prefix PREFIX_DIR | ||
+ | | ||
+ | -u, --uid UID new UID for the user account | ||
+ | -U, --unlock | ||
+ | -v, --add-subuids FIRST-LAST | ||
+ | -V, --del-subuids FIRST-LAST | ||
+ | -w, --add-subgids FIRST-LAST | ||
+ | -W, --del-subgids FIRST-LAST | ||
+ | -Z, --selinux-user SEUSER | ||
</ | </ | ||
- | Les valeurs | + | <WRAP center round important> |
+ | **Important** : Notez l' | ||
+ | </ | ||
+ | |||
+ | ===passwd=== | ||
- | Par exemple si les valeurs sur un système muni d' | + | Cette commande est utilisée pour créer ou modifier le mot de passe d' |
- | * 2,48 processus en attente dans la dernière minute, | + | Les options de cette commande |
- | * 3,00 processus en attente dans les dernières 5 minutes, | + | |
- | * 2,85 processus en attente dans les dernières 15 minutes. | + | |
- | + | ||
- | Les options de ces commandes | + | |
< | < | ||
- | root@debian8:~# uptime | + | root@debian11:~# passwd |
- | + | Usage: | |
- | Usage: | + | |
- | | + | |
Options: | Options: | ||
- | -p, --pretty | + | -a, --all |
- | -h, --help | + | -d, --delete |
- | -s, --since system up since | + | -e, --expire |
- | -V, --version | + | |
+ | -k, --keep-tokens | ||
+ | -i, --inactive INACTIVE | ||
+ | to INACTIVE | ||
+ | -l, --lock | ||
+ | -n, --mindays MIN_DAYS | ||
+ | change to MIN_DAYS | ||
+ | -q, --quiet | ||
+ | -r, --repository REPOSITORY | ||
+ | -R, --root CHROOT_DIR | ||
+ | -S, --status | ||
+ | -u, --unlock | ||
+ | -w, --warndays WARN_DAYS | ||
+ | -x, --maxdays MAX_DAYS | ||
+ | change to MAX_DAYS | ||
+ | </ | ||
- | For more details see uptime(1). | + | <WRAP center round important> |
+ | **Important** : Notez l' | ||
+ | </ | ||
- | root@debian8: | + | ===chage=== |
- | Usage: | + | La commande chage modifie le nombre de jours entre les changements de mot de passe et la date du dernier changement. Ces informations sont utilisées par le système pour déterminer si un utilisateur doit changer son mot de passe. |
- | w [options] | + | |
- | Options: | + | Les options de cette commande sont : |
- | -h, --no-header | + | |
- | -u, --no-current | + | |
- | -s, --short | + | |
- | -f, --from | + | |
- | -o, --old-style | + | |
- | -i, --ip-addr | + | |
- | --help | + | < |
- | -V, --version | + | root@debian11: |
+ | Usage: chage [options] LOGIN | ||
- | For more details see w(1). | + | Options: |
+ | -d, --lastday LAST_DAY | ||
+ | -E, --expiredate EXPIRE_DATE | ||
+ | -h, --help | ||
+ | -i, --iso8601 | ||
+ | -I, --inactive INACTIVE | ||
+ | to INACTIVE | ||
+ | -l, --list | ||
+ | -m, --mindays MIN_DAYS | ||
+ | change to MIN_DAYS | ||
+ | -M, --maxdays MAX_DAYS | ||
+ | change to MAX_DAYS | ||
+ | -R, --root CHROOT_DIR | ||
+ | -W, --warndays WARN_DAYS | ||
</ | </ | ||
- | ==iostat== | + | =====Configuration===== |
- | Sous Debian 8 les commandes | + | La commande |
< | < | ||
- | root@debian8:~# apt-get install sysstat | + | root@debian11:~# cat / |
- | Reading package lists... Done | + | # Default values for useradd(8) |
- | Building dependency tree | + | # |
- | Reading state information... Done | + | # The SHELL variable specifies the default login shell on your |
- | Suggested packages: | + | # system. |
- | isag | + | # Similar |
- | The following NEW packages will be installed: | + | # useradd is a low level utility and should |
- | | + | # as possible |
- | 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. | + | SHELL=/bin/sh |
- | Need to get 290 kB of archives. | + | # |
- | After this operation, 1,390 kB of additional disk space will be used. | + | # The default group for users |
- | Get:1 http://ftp.fr.debian.org/ | + | # 100=users on Debian systems |
- | Fetched 290 kB in 5s (53.4 kB/s) | + | # Same as USERS_GID |
- | Preconfiguring packages ... | + | # This argument is used when the -n flag is specified. |
- | Selecting previously unselected package sysstat. | + | # The default behavior |
- | (Reading database ... 167520 files and directories currently installed.) | + | # primary user group with the same name as the user being added to the |
- | Preparing | + | # system. |
- | Unpacking sysstat (11.0.1-1) ... | + | # GROUP=100 |
- | Processing triggers for man-db (2.7.0.2-5) ... | + | # |
- | Processing triggers for systemd (215-17+deb8u2) ... | + | # The default home directory. Same as DHOME for adduser |
- | Setting up sysstat (11.0.1-1) ... | + | # HOME=/home |
- | + | # | |
- | Creating config file /etc/default/sysstat with new version | + | # The number of days after a password expires until the account |
- | update-alternatives: | + | # is permanently disabled |
- | Processing triggers for systemd (215-17+deb8u2) ... | + | # INACTIVE=-1 |
+ | # | ||
+ | # The default | ||
+ | # EXPIRE= | ||
+ | # | ||
+ | # The SKEL variable specifies the directory containing " | ||
+ | # files; in other words, files such as a sample | ||
+ | # copied | ||
+ | # SKEL=/etc/skel | ||
+ | # | ||
+ | # Defines whether the mail spool should be created while | ||
+ | # creating the account | ||
+ | # CREATE_MAIL_SPOOL=yes | ||
</ | </ | ||
- | La commande **iostat** affiche des statistiques sur l' | + | Dans ce fichier, nous trouvons les directives suivantes |
- | < | + | * **SHELL** - renseigne le shell de l' |
- | root@debian8: | + | * **GROUP** |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | * **HOME** - indique que le répertoire personnel de l' |
+ | * **INACTIVE** - indique le nombre de jours d' | ||
+ | * **EXPIRE** - sans valeur, cette directive indique que le mot de passe de l' | ||
+ | * **SKEL** - indique le répertoire contenant les fichiers qui seront copiés vers le répertoire personnel de l' | ||
+ | * **CREATE_MAIL_SPOOL** - indique si oui ou non une boite mail interne au système sera créée pour l' | ||
- | avg-cpu: | + | Il est aussi possible de renseigner la valeur de la directive suivante |
- | 27.19 0.00 5.79 0.80 0.00 66.22 | + | |
- | Device: | + | * **UMASK** |
- | sda | + | |
- | </ | + | |
- | + | ||
- | Au-dessous de la première ligne indiquant la version du noyau du système et son nom d' | + | |
- | + | ||
- | * Pourcentage de temps passé en mode utilisateur | + | |
- | * Pourcentage de temps passé en mode utilisateur (pour les processus qui ont modifié leur priorité de programmation à l'aide de la commande nice) | + | |
- | * Pourcentage de temps passé en mode noyau | + | |
- | * Pourcentage de temps passé en inactivité | + | |
- | + | ||
- | Notez la valeur | + | |
- | + | ||
- | Pour surveiller | + | |
- | Sous Debian 8, la commande **hdparm** n'est pas disponible par défaut. Installez donc le paquet | + | Ces mêmes informations peuvent être visualisées en exécutant |
< | < | ||
- | root@debian8:~# apt-get install hdparm | + | root@debian11:~# useradd |
- | Reading package lists... Done | + | GROUP=100 |
- | Building dependency tree | + | HOME=/home |
- | Reading state information... Done | + | INACTIVE=-1 |
- | The following extra packages will be installed: | + | EXPIRE= |
- | powermgmt-base | + | SHELL=/bin/sh |
- | Suggested packages: | + | SKEL=/etc/skel |
- | apmd | + | CREATE_MAIL_SPOOL=no |
- | The following NEW packages will be installed: | + | |
- | hdparm powermgmt-base | + | |
- | 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. | + | |
- | Need to get 118 kB of archives. | + | |
- | After this operation, 263 kB of additional disk space will be used. | + | |
- | Do you want to continue? [Y/n] y | + | |
- | Get:1 http:// | + | |
- | Get:2 http://ftp.fr.debian.org/ | + | |
- | Fetched 118 kB in 0s (264 kB/s) | + | |
- | Selecting previously unselected package hdparm. | + | |
- | (Reading database ... 167600 files and directories currently installed.) | + | |
- | Preparing to unpack .../ | + | |
- | Unpacking hdparm (9.43-2) ... | + | |
- | Selecting previously unselected package powermgmt-base. | + | |
- | Preparing to unpack .../ | + | |
- | Unpacking powermgmt-base (1.31+nmu1) ... | + | |
- | Processing triggers for systemd (215-17+deb8u2) ... | + | |
- | Processing triggers for man-db (2.7.0.2-5) ... | + | |
- | Setting up hdparm (9.43-2) ... | + | |
- | update-rc.d: | + | |
- | Setting up powermgmt-base (1.31+nmu1) ... | + | |
- | Processing triggers for systemd (215-17+deb8u2) ... | + | |
</ | </ | ||
- | Exécutez maintenant | + | Pour consulter |
< | < | ||
- | root@debian8:~# hdparm | + | root@debian11:~# ls -la /etc/skel |
- | + | total 20 | |
- | /dev/sda: | + | drwxr-xr-x |
- | Timing buffered disk reads: 228 MB in 3.13 seconds = 72.76 MB/sec | + | drwxr-xr-x 112 root root 4096 Jun 2 16:42 .. |
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
</ | </ | ||
- | Au-dessous du rapport d' | + | <WRAP center round important> |
+ | **Important** : Notez que sous Debian | ||
+ | </ | ||
- | * La spécification du périphérique, apparaissant sous la forme dev< | + | Pour connaître l'UID, le GID et l' |
- | * Le nombre de transferts (ou opérations | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | Les options de cette commande | + | |
< | < | ||
- | root@debian8:~# iostat --help | + | root@debian11:~# id trainee |
- | Usage: iostat [ options ] [ < | + | uid=1000(trainee) gid=1000(trainee) groups=1000(trainee),24(cdrom), |
- | Options are: | + | |
- | [ -c ] [ -d ] [ -h ] [ -k | -m ] [ -N ] [ -t ] [ -V ] [ -x ] [ -y ] [ -z ] | + | |
- | [ -j { ID | LABEL | PATH | UUID | ... } ] | + | |
- | [ [ -T ] -g < | + | |
- | [ < | + | |
</ | </ | ||
- | ==vmstat== | + | Pour seulement connaître les groupes d'un utilisateur, |
- | + | ||
- | La commande **vmstat** affiche des statistiques sur la mémoire, la pagination et la charge ponctuelle du processeur | + | |
< | < | ||
- | root@debian8:~# vmstat 1 10 | + | root@debian11:~# groups trainee |
- | procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- | + | trainee : trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
</ | </ | ||
- | La première ligne subdivise le champ en six catégories à savoir : processus, mémoire, swap, E/S, système et CPU sur lesquelles elle donne des statistiques. La seconde ligne identifie | + | Les valeurs minimales |
- | Les champs relatifs aux processus sont les suivants : | + | < |
+ | ... | ||
+ | # | ||
+ | # Min/max values for automatic uid selection in useradd | ||
+ | # | ||
+ | UID_MIN | ||
+ | UID_MAX | ||
+ | # System accounts | ||
+ | # | ||
+ | # | ||
- | * r — Le nombre de processus exécutables attendant d' | + | # |
- | * b — Le nombre de processus exécutables dans un état de veille qui ne peut être interrompu | + | # Min/max values for automatic gid selection in groupadd |
+ | # | ||
+ | GID_MIN | ||
+ | GID_MAX | ||
+ | # System accounts | ||
+ | # | ||
+ | # | ||
+ | ... | ||
+ | </ | ||
- | Les champs relatifs à la mémoire sont les suivants : | + | =====LAB #1 - Gérer |
- | | + | Créez maintenant trois groupes |
- | | + | |
- | | + | |
- | | + | |
- | Les champs relatifs au swap sont les suivants | + | < |
+ | root@debian11:~# groupadd groupe1; groupadd groupe2; groupadd -g 1807 groupe3 | ||
+ | </ | ||
- | | + | Créez maintenant trois utilisateurs |
- | | + | |
- | Les champs relatifs aux Entrées/ | + | < |
+ | root@debian11:~# useradd -g groupe2 fenestros2; useradd -g 1807 fenestros3; useradd -g groupe1 fenestros1 | ||
- | * bi — Blocs envoyés vers un périphérique blocs | + | root@debian11: |
- | * bo— Blocs reçus d'un périphérique blocs | + | |
- | Les champs relatifs au système sont les suivants | + | root@debian11:~# usermod -c " |
+ | </ | ||
- | | + | En consultant la fin de votre fichier |
- | | + | |
- | Les champs relatifs au CPU sont les suivants | + | < |
+ | root@debian11:~# tail / | ||
+ | pulse: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | sshd: | ||
+ | fenestros2: | ||
+ | fenestros3: | ||
+ | fenestros1: | ||
+ | </ | ||
- | * us — Le pourcentage | + | En regardant la fin de votre fichier |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | root@debian8:~# vmstat | + | root@debian11:~# tail / |
+ | scanner: | ||
+ | saned: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | mlocate: | ||
+ | groupe1: | ||
+ | groupe2: | ||
+ | groupe3: | ||
+ | </ | ||
- | Usage: | + | Créez le mot de passe **fenestros** pour le **groupe3** |
- | | + | |
- | Options: | + | <code> |
- | -a, --active | + | root@debian11: |
- | -f, --forks | + | Changing the password for group groupe3 |
- | -m, --slabs | + | New Password: fenestros |
- | -n, --one-header | + | Re-enter new password: fenestros |
- | -s, --stats | + | |
- | -d, --disk | + | |
- | -D, --disk-sum | + | |
- | -p, --partition | + | |
- | -S, --unit < | + | |
- | -w, --wide | + | |
- | + | ||
- | -h, --help | + | |
- | -V, --version | + | |
- | + | ||
- | For more details see vmstat(8). | + | |
</ | </ | ||
<WRAP center round important> | <WRAP center round important> | ||
- | **Important** : Par défaut la commande vmstat affiche des informations depuis le démarrage du système. | + | **Important** : Notez que les mots de passe saisis ne seront **pas** visibles. |
</ | </ | ||
- | ==mpstat== | + | Consultez la fin de votre fichier |
- | + | ||
- | La commande | + | |
< | < | ||
- | root@debian8:~# mpstat | + | root@debian11:~# tail /etc/gshadow |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | scanner: |
- | + | saned:!:: | |
- | 09:54:31 AM CPU %usr | + | colord:!:: |
- | 09:54:31 AM all 27.49 0.00 5.59 0.77 0.00 0.22 0.00 0.00 0.00 65.92 | + | lightdm: |
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | mlocate: | ||
+ | groupe1: | ||
+ | groupe2: | ||
+ | groupe3: | ||
</ | </ | ||
- | Dans le cas où vous avez plusieurs processeurs ou coeurs, vous pouvez visualiser ces mêmes informations par unité de traitement | + | <WRAP center round important> |
+ | **Important** | ||
+ | </ | ||
- | < | + | Nommez maintenant **fenestros1** administrateur du **groupe3** |
- | root@debian8:~# mpstat -P ALL | + | |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | |
- | 09:54:59 AM CPU %usr | + | < |
- | 09:54:59 AM all | + | root@debian11:~# gpasswd -A fenestros1 groupe3 |
- | 09:54:59 AM 0 | + | |
</ | </ | ||
- | Pour afficher 5 jeux de statistiques à des intervales | + | Consultez la fin de votre fichier **/ |
< | < | ||
- | root@debian8:~# mpstat | + | root@debian11:~# tail / |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | scanner: |
+ | saned:!:: | ||
+ | colord: | ||
+ | lightdm: | ||
+ | trainee: | ||
+ | systemd-coredump: | ||
+ | mlocate: | ||
+ | groupe1: | ||
+ | groupe2: | ||
+ | groupe3: | ||
+ | </code> | ||
- | 09:59:58 AM CPU %usr | + | <WRAP center round important> |
- | 10:00:00 AM all 24.10 0.00 6.15 0.00 0.00 0.51 0.00 0.00 0.00 69.23 | + | **Important** |
- | 10:00:00 AM 0 | + | </ |
- | 10:00:00 AM CPU %usr | + | Essayez maintenant de supprimer le groupe **groupe3** |
- | 10:00:02 AM all | + | |
- | 10:00:02 AM 0 | + | |
- | 10:00:02 AM CPU %usr | + | < |
- | 10:00:04 AM all | + | root@debian11:~# groupdel groupe3 |
- | 10:00:04 AM 0 | + | groupdel: cannot remove the primary group of user ' |
+ | </ | ||
- | 10:00:04 AM CPU %usr | + | <WRAP center round important> |
- | 10:00:06 AM all 36.32 0.00 6.32 0.00 0.00 0.00 0.00 0.00 0.00 57.37 | + | **Important** |
- | 10:00:06 AM 0 | + | </ |
- | 10:00:06 AM CPU %usr | + | Supprimez donc l' |
- | 10:00:08 AM all | + | |
- | 10:00:08 AM 0 | + | |
- | Average: | + | < |
- | Average: | + | root@debian11:~# userdel fenestros3 |
- | Average: 0 | + | |
</ | </ | ||
- | Les options | + | Ensuite essayez |
< | < | ||
- | root@debian8:~# mpstat --help | + | root@debian11:~# groupdel groupe3 |
- | Usage: mpstat [ options ] [ < | + | |
- | Options are: | + | |
- | [ -A ] [ -u ] [ -V ] [ -I { SUM | CPU | SCPU | ALL } ] | + | |
- | [ -P { <cpu> [,...] | ON | ALL } ] | + | |
</ | </ | ||
- | ==sar== | + | <WRAP center round important> |
+ | **Important** : Notez que cette fois-ci la commande est exécutée sans erreur. | ||
+ | </ | ||
- | La commande | + | Le fait de supprimer un utilisateur |
- | ^ Option ^ Description ^ | + | Sous Debian |
- | | -u | Pourcentage d' | + | |
- | | -q | Nombre de processus en attente | | + | |
- | | -r | Utilisation de la mémoire centrale | | + | |
- | | -w | Surveillance du swapping | | + | |
- | | -p | Surveillance de la pagination | | + | |
- | | -b | Utilisation des tampons | | + | |
- | | -d | Utilisation des disques | | + | |
- | + | ||
- | Sous Debian | + | |
< | < | ||
- | root@debian8:~# ls /usr/lib/sysstat/ | + | root@debian11:~# cat /etc/default/useradd |
- | debian-sa1 sa1 sa2 sadc | + | # Default values for useradd(8) |
+ | # | ||
+ | # The SHELL variable specifies the default login shell on your | ||
+ | # system. | ||
+ | # Similar to DSHELL in adduser. However, we use " | ||
+ | # useradd is a low level utility and should be as general | ||
+ | # as possible | ||
+ | SHELL=/bin/sh | ||
+ | # | ||
+ | # The default group for users | ||
+ | # 100=users on Debian systems | ||
+ | # Same as USERS_GID in adduser | ||
+ | # This argument is used when the -n flag is specified. | ||
+ | # The default behavior (when -n and -g are not specified) is to create a | ||
+ | # primary user group with the same name as the user being added to the | ||
+ | # system. | ||
+ | # GROUP=100 | ||
+ | # | ||
+ | # The default home directory. Same as DHOME for adduser | ||
+ | # HOME=/ | ||
+ | # | ||
+ | # The number of days after a password expires until the account | ||
+ | # is permanently disabled | ||
+ | # INACTIVE=-1 | ||
+ | # | ||
+ | # The default expire date | ||
+ | # EXPIRE= | ||
+ | # | ||
+ | # The SKEL variable specifies the directory containing " | ||
+ | # files; in other words, files such as a sample .profile that will be | ||
+ | # copied to the new user's home directory when it is created. | ||
+ | # SKEL=/ | ||
+ | # | ||
+ | # Defines whether the mail spool should be created while | ||
+ | # creating the account | ||
+ | # CREATE_MAIL_SPOOL=yes | ||
</ | </ | ||
- | Les scripts **/ | + | Otez donc le caractère |
- | ^ Option ^ Description ^ | + | < |
- | | -t | L' | + | root@debian11: |
- | | -n | Nombre de collectes | | + | |
- | Les scripts **/ | + | root@debian11:~# cat / |
- | + | # Default values for useradd(8) | |
- | Pour pouvoir fonctionner correctement, | + | |
- | + | ||
- | Pour activer la collecte des données sous Debian 8, éditez le fichier **/ | + | |
- | + | ||
- | < | + | |
- | root@debian8:~# cat / | + | |
# | # | ||
- | # Default settings for /etc/init.d/sysstat, / | + | # The SHELL variable specifies the default login shell on your |
- | # and /etc/ | + | # system. |
+ | # Similar to DSHELL in adduser. However, we use " | ||
+ | # useradd is a low level utility | ||
+ | # as possible | ||
+ | SHELL=/bin/sh | ||
# | # | ||
- | + | # The default group for users | |
- | # Should sadc collect system activity informations? | + | # 100=users on Debian systems |
- | # are "true" | + | # Same as USERS_GID in adduser |
- | # will be overwritten by debconf! | + | # This argument is used when the -n flag is specified. |
- | ENABLED=" | + | # The default behavior (when -n and -g are not specified) is to create a |
+ | # primary user group with the same name as the user being added to the | ||
+ | # system. | ||
+ | GROUP=100 | ||
+ | # | ||
+ | # The default home directory. Same as DHOME for adduser | ||
+ | HOME=/ | ||
+ | # | ||
+ | # The number of days after a password expires until the account | ||
+ | # is permanently disabled | ||
+ | INACTIVE=-1 | ||
+ | # | ||
+ | # The default expire date | ||
+ | EXPIRE= | ||
+ | # | ||
+ | # The SKEL variable specifies the directory containing | ||
+ | # files; in other words, files such as a sample .profile that will be | ||
+ | # copied to the new user's home directory when it is created. | ||
+ | SKEL=/ | ||
+ | # | ||
+ | # Defines whether the mail spool should | ||
+ | # creating the account | ||
+ | CREATE_MAIL_SPOOL=yes | ||
</ | </ | ||
- | Modifiez le fichier **/ | + | Pour tester la configuration, |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# useradd |
- | # The first element of the path is a directory where the debian-sa1 | + | </code> |
- | # script is located | + | |
- | PATH=/ | + | |
- | # Activity reports every 10 minutes everyday | + | Vérifiez que l' |
- | #5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 | + | |
- | */2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1 | + | |
- | # Additional run at 23:59 to rotate the statistics file | + | < |
- | 59 23 * * * root command | + | root@debian11: |
+ | total 8 | ||
+ | drwxr-xr-x | ||
+ | drwxr-xr-x 17 trainee trainee 4096 Jun 3 17:39 trainee | ||
</ | </ | ||
- | Attendez deux minutes puis saisissez | + | Créez maintenant |
< | < | ||
- | root@debian8:~# sar | + | root@debian11:~# mkdir /home/fenestros1 / |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | |
- | + | ||
- | 01:35:01 PM | + | |
- | 01:40:01 PM | + | |
- | Average: | + | |
</ | </ | ||
+ | |||
+ | Copiez le contenu du répertoire **/ | ||
< | < | ||
- | root@debian8:~# sar -u 5 3 | + | root@debian11:~# cp -r /etc/skel/.[a-zA-Z]* /home/fenestros1 |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | root@debian11:~# cp -r /etc/skel/.[a-zA-Z]* / |
- | + | ||
- | 01:41:52 PM | + | |
- | 01:41:57 PM | + | |
- | 01:42:02 PM | + | |
- | 01:42:07 PM | + | |
- | Average: | + | |
</ | </ | ||
+ | |||
+ | Modifiez le propriétaire et le groupe pour les répertoires **/ | ||
< | < | ||
- | root@debian8:~# sar -r 5 3 | + | root@debian11:~# chown -R fenestros1: |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | root@debian11:~# chown -R fenestros2:groupe2 / |
- | + | ||
- | 01:42:53 PM kbmemfree kbmemused | + | |
- | 01:42:58 PM 221948 | + | |
- | 01:43:03 PM 221892 | + | |
- | 01:43:08 PM 221912 | + | |
- | Average: | + | |
</ | </ | ||
- | < | + | Créez maintenant les mots de passe pour **fenestros1** et **fenestros2**. Indiquez un mot de passe identique au nom du compte |
- | root@debian8: | + | |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | |
- | + | ||
- | 01:43:54 PM proc/ | + | |
- | 01:43:59 PM 0.00 539.92 | + | |
- | 01:44:04 PM 1.24 599.18 | + | |
- | 01:44:09 PM 0.00 317.45 | + | |
- | Average: | + | |
- | </ | + | |
< | < | ||
- | root@debian8:~# sar -b 5 3 | + | root@debian11:~# passwd fenestros1 |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | New password: fenestros1 |
- | + | Retype new password: fenestros1 | |
- | 01:44:36 PM | + | passwd: password updated successfully |
- | 01:44:41 PM 2.44 0.00 2.44 0.00 30.16 | + | root@debian11:~# passwd fenestros2 |
- | 01:44:46 PM 0.00 0.00 0.00 0.00 0.00 | + | New password: fenestros2 |
- | 01:44:51 PM 0.00 0.00 0.00 0.00 0.00 | + | Retype new password: fenestros2 |
- | Average: 0.78 0.00 0.78 0.00 9.64 | + | passwd: password updated successfully |
</ | </ | ||
- | <code> | + | <WRAP center round important> |
- | root@debian8:~# sar -d 5 3 | + | **Important** |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | </WRAP> |
- | 01:44:48 PM | + | =====LAB #2 - Forcer l' |
- | 01:44:53 PM dev8-0 | + | |
- | 01:44:53 PM | + | ====2.1 |
- | 01:44:58 PM dev8-0 | + | |
- | 01:44:58 PM | + | **PAM** ( //Pluggable Authentification Modules// ou Modules d' |
- | 01:45:03 PM dev8-0 | + | |
- | Average: | + | Les fichiers de configuration se trouvent dans le répertoire **/etc/pam.d** |
- | Average: dev8-0 | + | |
- | </ | + | |
< | < | ||
- | root@debian8:~# sar -p 5 3 | + | root@debian11:~# ls -l /etc/pam.d |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | total 104 |
- | + | -rw-r--r-- 1 root root 384 Feb 7 2020 chfn | |
- | 01:45:23 PM | + | -rw-r--r-- 1 root root 92 Feb 7 2020 chpasswd |
- | 01:45:28 PM | + | -rw-r--r-- 1 root root 581 Feb 7 2020 chsh |
- | 01:45:33 PM | + | -rw-r--r-- 1 root root 1208 Apr 25 06:49 common-account |
- | 01:45:38 PM | + | -rw-r--r-- 1 root root 1214 Apr 25 06:49 common-auth |
- | Average: | + | -rw-r--r-- 1 root root 1660 Apr 25 06:49 common-password |
+ | -rw-r--r-- 1 root root 1146 Apr 25 06:49 common-session | ||
+ | -rw-r--r-- 1 root root 1154 Apr 25 06:49 common-session-noninteractive | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- 1 root root 69 May 27 2021 cups | ||
+ | -rw-r--r-- 1 root root 1354 Feb 3 2020 lightdm | ||
+ | -rw-r--r-- 1 root root 1428 Feb 3 2020 lightdm-autologin | ||
+ | -rw-r--r-- 1 root root 493 Feb 3 2020 lightdm-greeter | ||
+ | -rw-r--r-- 1 root root 4126 Feb 7 2020 login | ||
+ | -rw-r--r-- 1 root root 92 Feb 7 2020 newusers | ||
+ | -rw-r--r-- 1 root root 520 Jan 30 2021 other | ||
+ | -rw-r--r-- 1 root root 92 Feb 7 2020 passwd | ||
+ | -rw-r--r-- 1 root root 270 Jan 13 20:32 polkit-1 | ||
+ | -rw-r--r-- 1 root root 168 Jan 7 2021 ppp | ||
+ | -rw-r--r-- 1 root root 143 Jan 20 20:55 runuser | ||
+ | -rw-r--r-- 1 root root 138 Jan 20 20:55 runuser-l | ||
+ | -rw-r--r-- 1 root root 2133 Mar 13 2021 sshd | ||
+ | -rw-r--r-- 1 root root 2259 Jan 20 20:55 su | ||
+ | -rw-r--r-- 1 root root 95 Feb 27 2021 sudo | ||
+ | -rw-r--r-- 1 root root 137 Jan 20 20:55 su-l | ||
</ | </ | ||
+ | |||
+ | Ces fichiers ont une structure spécifique et sont nommés d' | ||
< | < | ||
- | root@debian8:~# sar -v 5 3 | + | root@debian11:~# ls /lib/x86_64-linux-gnu/ |
- | Linux 3.16.0-4-686-pae (debian8) 11/02/2015 _i686_ (1 CPU) | + | pam_access.so pam_faildelay.so pam_issue.so |
- | + | pam_debug.so | |
- | 01:45:58 PM dentunusd | + | pam_deny.so |
- | 01:46:03 PM | + | pam_echo.so |
- | 01:46:08 PM | + | pam_env.so |
- | 01:46:13 PM | + | pam_exec.so |
- | Average: | + | |
</ | </ | ||
- | Les options | + | Les modules les plus importants sont : |
+ | |||
+ | ^ Module ^ Description ^ | ||
+ | | pam_access.so | Ce module est utilisé pour interdire l' | ||
+ | | pam_echo.so | Ce module présente le contenu du fichier passé en argument à tout utilisateur lors de sa connexion. | | ||
+ | | pam_limits.so | Ce module implémente les limites des ressources détaillées dans le fichier **/ | ||
+ | | pam_listfile.so | Ce module est utilisé pour consulter un fichier spécifique pour vérifier les authiorisations. Par exemple, le service ftp utilise ce module pour consulter le fichier **/ | ||
+ | | pam_nologin.so | Ce module interdit les connexions d' | ||
+ | | pam_securetty.so | Ce module interdit des connexions | ||
+ | | pam_unix.so | Ce module est utilisé pour vérifier les informations suivantes ; expire, last_change, | ||
+ | |||
+ | Chaque fichier dans /etc/pam.d contient les règles PAM utilisées pendant l' | ||
< | < | ||
- | root@debian8:~# sar --help | + | root@debian11:~# cat /etc/pam.d/login |
- | Usage: sar [ options ] [ < | + | # |
- | Options are: | + | # The PAM configuration file for the Shadow `login' |
- | [ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F ] [ -H ] [ -h ] [ -p ] [ -q ] | + | # |
- | [ -R ] [ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ] | + | |
- | [ -I { <int> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ] | + | |
- | [ -m { < | + | |
- | [ -j { ID | LABEL | PATH | UUID | ... } ] | + | |
- | [ -f [ < | + | |
- | [ -i < | + | |
- | </ | + | |
- | ===Utilisation des commandes en production=== | + | # Enforce a minimal delay in case of failure (in microseconds). |
+ | # (Replaces the `FAIL_DELAY' | ||
+ | # Note that other modules may require another minimal delay. (for example, | ||
+ | # to disable any delay, you should add the nodelay option to pam_unix) | ||
+ | auth | ||
- | ==Identifier un système limité par le processeur== | + | # Outputs an issue file prior to each login prompt (Replaces the |
+ | # ISSUE_FILE option from login.defs). Uncomment for use | ||
+ | # auth | ||
- | Dans ce cas utilisez les commandes suivantes : | + | # Disallows other than root logins when / |
+ | # (Replaces the `NOLOGINS_FILE' | ||
+ | auth | ||
- | * uptime ou w | + | # SELinux needs to be the first session rule. This ensures that any |
- | * vmstat | + | # lingering context has been cleared. Without this it is possible |
- | * mpstat -P ALL | + | # that a module could execute code in the wrong domain. |
- | * sar -u | + | # When the module is present, " |
- | * iostat -c | + | # is disabled, this returns success.) |
+ | session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close | ||
- | ==Identifier un système ayant un problème de mémoire== | + | # Sets the loginuid process attribute |
+ | session | ||
- | Dans ce cas utilisez les commandes suivantes : | + | # Prints the message of the day upon successful login. |
+ | # (Replaces the `MOTD_FILE' | ||
+ | # This includes a dynamically generated part from / | ||
+ | # and a static (admin-editable) part from / | ||
+ | session | ||
+ | session | ||
- | * free | + | # SELinux needs to intervene at login time to ensure that the process |
- | * sar -B | + | # starts in the proper default security context. Only sessions which are |
+ | # intended to run in the user's context should be run after this. | ||
+ | # pam_selinux.so changes the SELinux context of the used TTY and configures | ||
+ | # SELinux in order to transition to the user context with the next execve() | ||
+ | # call. | ||
+ | session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open | ||
+ | # When the module is present, " | ||
+ | # is disabled, this returns success.) | ||
- | ==Identifier un système ayant un problème d'E/S== | + | # This module parses environment configuration file(s) |
+ | # and also allows you to use an extended config | ||
+ | # file / | ||
+ | # | ||
+ | # parsing / | ||
+ | session | ||
+ | # locale variables are also kept into /etc/ | ||
+ | # reading this file *in addition to / | ||
+ | session | ||
- | Utilisez la commande : | + | # Standard Un*x authentication. |
+ | @include common-auth | ||
- | | + | # This allows certain extra groups to be granted to a user |
+ | # based on things like time of day, tty, service, and user. | ||
+ | # Please edit / | ||
+ | # (Replaces the `CONSOLE_GROUPS' | ||
+ | auth | ||
- | =====Modules usb===== | + | # Uncomment and edit / |
+ | # time restraint on logins. | ||
+ | # (Replaces the `PORTTIME_CHECKS_ENAB' | ||
+ | # as well as / | ||
+ | # account | ||
- | L' | + | # Uncomment and edit /etc/security/access.conf if you need to |
+ | # set access limits. | ||
+ | # (Replaces | ||
+ | # account | ||
- | ^ Version USB ^ Module ^ Nom Complet ^ | + | # Sets up user limits according to /etc/security/limits.conf |
- | | 1.0\1.1 | + | # (Replaces the use of /etc/limits in old login) |
- | | ::: | **OHCI** | //Open Controller Host Interface// | | + | session |
- | | 2.0 | **EHCI** | //Enhanced Host Controller Interface// | | + | |
- | | 3.0 | **XHCI** | // | + | |
- | Le tableau suivant liste les modules courrament chargés en fonction du périphérique utilisé : | + | # Prints the last login info upon successful login |
+ | # (Replaces the `LASTLOG_ENAB' | ||
+ | session | ||
- | ^ Module ^ Type de Périphérique ^ | + | # Prints the status of the user's mailbox upon successful login |
- | | **usb_storage** | + | # (Replaces the `MAIL_CHECK_ENAB' |
- | | **usbhid** | + | # |
- | | **snd-usb-audio** | + | # This also defines the MAIL environment variable |
- | | **usbvidéo** | + | # However, userdel also needs MAIL_DIR and MAIL_FILE variables |
- | | **irda-usb** | + | # in / |
- | | **usbnet** | + | # also removes the user's mail spool file. |
+ | # See comments in / | ||
+ | session | ||
- | Les modules peuvent être chargés par un des moyens suivants : | + | # Create a new session keyring. |
+ | session | ||
- | | + | # Standard Un*x account and session |
- | * Le processus init, | + | @include common-account |
- | * kmod, d'une manière dynamique et transparente lors du branchement du périphérique, | + | @include common-session |
- | * udev, | + | @include common-password |
- | * manuellement. | + | </ |
- | <WRAP center round todo> | + | La première ligne de ce fichier est un commentaire qui spécifie que le fichier est conforme à la spécification PAM 1.0. |
- | **A faire** : Branchez une clef USB avant de continuer. Si vous utilisez %%VirtualBox%%, | + | |
- | </ | + | |
- | =====udev===== | + | Ce fichier, tout comme les autres, est ensuite structuré de la façon suivante : |
- | Depuis le noyau Linux 2.6 Linux est capable de détecter des périphériques branchés à chaud. Cette technologie s' | + | |
+ | | ||
- | | + | Le **premier champs** est le //**type de module**//. Il en existe quatre : |
- | | + | |
- | | + | |
- | Les rôles de chaque composant sont les suivants : | + | ^ Type ^ Description ^ |
+ | | **auth** | Utilisé pour authentifier un utilisateur ou les pré-requis système ( par exemple / | ||
+ | | **account** | Utilisé pour vérifier si l' | ||
+ | | **password** | Utilisé pour vérifier si l' | ||
+ | | **session** | Utilisé pour gérer la session après l' | ||
- | | + | Le **deuxième champs** est le //**Control-flag**//. Il en existe quatre : |
- | | + | |
- | * Dbus joue le rôle d'un bus système qui est utilisé pour la communication inter-processus. | + | |
- | Lors de démarrage | + | ^ Control-flag ^ Description ^ |
+ | | **required** | La réussite | ||
+ | | **requisite** | La réussite de ce module est indispensable. L' | ||
+ | | **sufficient** | La réussite de ce module est suffisant pour authoriser l' | ||
+ | | **optional** | La réussite ou l' | ||
+ | | **@include** | Ce control-flag permet d' | ||
- | | + | Le **troisième champs** stipule le //**module**// associé à la règle. Sans chemin absolu, le fichier est supposé être dans le répertoire **/lib/x86_64-linux-gnu/security**. Pour inclure un module |
- | | + | |
- | * le démon **udevd** collecte des données appelées **uevents** du noyau et cherche une règle correspondante | + | |
- | * Udev crée les nœuds et liens symboliques spécifiés dans la règle identifiée, | + | |
- | * Udev stocke les règles contenues dans **/ | + | |
- | * En cas de modification des ces règles, Udev met à jour la mémoire. | + | |
- | Udev repose sur le filesystem | + | Le **quatrième champs** contient éventuellement |
- | Le fichier | + | Dernièrement, |
< | < | ||
- | root@debian8:~# cat /etc/udev/udev.conf | + | root@debian11:~# cat /etc/pam.d/other |
- | # see udev(7) for details | + | |
# | # | ||
- | # udevd is started in the initramfs, so when this file is modified | + | # / |
- | # initramfs should be rebuilt. | + | # |
+ | # Note that this file is used for any unspecified service; for example | ||
+ | #if / | ||
+ | # | ||
+ | #used. If you really want nothing to happen then use pam_permit.so or | ||
+ | # | ||
- | #udev_log=" | + | # We fall back to the system default in /etc/ |
- | </code> | + | # |
- | Les fichiers de règles se trouvent dans **/ | + | @include common-auth |
- | + | @include common-account | |
- | < | + | @include common-password |
- | root@debian8:~# ls / | + | @include common-session |
- | 39-usbmuxd.rules | + | |
- | 40-usb-media-players.rules | + | |
- | 40-usb_modeswitch.rules | + | |
- | 42-usb-hid-pm.rules | + | |
- | 50-bluetooth-hci-auto-poweron.rules | + | |
- | 50-firmware.rules | + | |
- | 50-udev-default.rules | + | |
- | 55-dm.rules | + | |
- | 56-hpmud.rules | + | |
- | 60-cdrom_id.rules | + | |
- | 60-crda.rules | + | |
- | 60-drm.rules | + | |
- | 60-fuse.rules | + | |
- | 60-gnupg.rules | + | |
- | 60-keyboard.rules | + | |
- | 60-libgphoto2-6.rules | + | |
- | 60-libsane.rules | + | |
- | 60-open-vm-tools.rules | + | |
- | 60-persistent-alsa.rules | + | |
- | 60-persistent-input.rules | + | |
</ | </ | ||
- | <WRAP center round important> | + | ====2.2 - Configuration des modules==== |
- | **Important** : Il vous est possible d' | + | |
- | </ | + | |
- | Comme indique le nom de chaque fichier, le contenu est composé | + | Certains modules |
< | < | ||
- | root@debian8:~# cat /lib/udev/ | + | root@debian11:~# ls -l /etc/security |
- | # do not edit this file, it will be overwritten on update | + | total 48 |
- | + | -rw-r--r-- 1 root root 4564 Aug 26 2021 access.conf | |
- | SUBSYSTEM==" | + | -rw-r--r-- 1 root root 2234 Aug 26 2021 faillock.conf |
- | + | -rw-r--r-- 1 root root 3635 Aug 26 2021 group.conf | |
- | # select " | + | -rw-r--r-- 1 root root 2161 Aug 26 2021 limits.conf |
- | SUBSYSTEM==" | + | drwxr-xr-x 2 root root 4096 Aug 26 2021 limits.d |
- | SUBSYSTEM==" | + | -rw-r--r-- 1 root root 1637 Aug 26 2021 namespace.conf |
- | + | drwxr-xr-x 2 root root 4096 Aug 26 2021 namespace.d | |
- | SUBSYSTEM==" | + | -rwxr-xr-x 1 root root 1016 Aug 26 2021 namespace.init |
- | SUBSYSTEM==" | + | -rw------- 1 root root 0 Apr 25 06:30 opasswd |
- | ENV{MODALIAS}!="", | + | -rw-r--r-- 1 root root 2971 Aug 26 2021 pam_env.conf |
- | + | -rw-r--r-- 1 root root 419 Aug 26 2021 sepermit.conf | |
- | ACTION!=" | + | -rw-r--r-- 1 root root 2179 Aug 26 2021 time.conf |
- | + | ||
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | KERNEL==" | + | |
- | KERNEL==" | + | |
- | KERNEL==" | + | |
- | + | ||
- | SUBSYSTEM==" | + | |
- | KERNEL==" | + | |
- | + | ||
- | SUBSYSTEM==" | + | |
- | SUBSYSTEM==" | + | |
- | + | ||
- | --More-- | + | |
</ | </ | ||
- | Chaque règle prend la forme suivante : | + | Parmi les fichiers |
- | + | ||
- | KEY, [KEY, ...] NAME [, SYMLINK] | + | |
- | + | ||
- | Chaque KEY est un champ au format **type=valeur** qui doit correspondre à un périphérique unique. La valeur de type peut prendre plusieurs formes : | + | |
- | + | ||
- | ^ Type ^ Description ^ Exemples ^ | + | |
- | | BUS | Type de bus | usb, scsi, ide | | + | |
- | | KERNEL | Le nom par défault du périphérique donné par le noyau | hda, ttyUSB0, lp0 | | + | |
- | | SUBSYSTEM | Le nom noyau du sous-système, | + | |
- | | DRIVER | Le nom du pilote qui contrôle le périphérique | usb-storage | | + | |
- | | ID | Le numéro du périphérique sur son bus | PCI bus id, USB id | | + | |
- | | PLACE | Ne concerne que les périphériques USB et donne la position topologique du périphérique sur son bus | S/O | | + | |
- | | SYSFS{filename} | Le nom du fichier dans /sys pour le périphérique. Ce fichier contient le fabricant, le label, le numéro de série et UUID du périphérique. La vérification de jusqu' | + | |
- | | PROGRAM | Ceci permet à Udev d' | + | |
- | | RESULT | Valeur à comparer au résultat de PROGRAM | S/O | | + | |
- | + | ||
- | NAME et SYMLINK sont utilisées pour stipuler ce que Udev doit faire avec le périphérique | + | |
- | ^ Type ^ Description ^ Exemples | + | ^ Fichier/// |
- | | NAME | Le nome du nœud dans /dev | S/O | | + | | **access.conf** |
- | | SYMLINK | + | | **faillock.conf** | pam_faillock.so |
+ | | **group.conf** | ||
+ | | **limits.conf** | pam_limits.so | | ||
+ | | **namespace.conf** | pam_namespace.so | | ||
+ | | **pam_env.conf** | pam_env.so | | ||
+ | | **sepermit.conf** | pam_sepermit.so | | ||
+ | | **time.conf** | pam_time.so | ||
- | ====La commande udevadm==== | + | ====2.3 - Utiliser des Mots de Passe Complexes==== |
- | Pour obtenir | + | La complexité des mots de passe est gérée par le module |
< | < | ||
- | root@debian8:~# udevadm info --query=all | + | root@debian11:~# apt-get -y install libpam-pwquality |
- | P: / | + | |
- | N: sda | + | |
- | S: disk/ | + | |
- | E: DEVLINKS=/ | + | |
- | E: DEVNAME=/ | + | |
- | E: DEVPATH=/ | + | |
- | E: DEVTYPE=disk | + | |
- | E: ID_ATA=1 | + | |
- | E: ID_ATA_FEATURE_SET_PM=1 | + | |
- | E: ID_ATA_FEATURE_SET_PM_ENABLED=1 | + | |
- | E: ID_ATA_SATA=1 | + | |
- | E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1 | + | |
- | E: ID_ATA_WRITE_CACHE=1 | + | |
- | E: ID_ATA_WRITE_CACHE_ENABLED=1 | + | |
- | E: ID_BUS=ata | + | |
- | E: ID_MODEL=VBOX_HARDDISK | + | |
- | E: ID_MODEL_ENC=VBOX\x20HARDDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 | + | |
- | E: ID_PART_TABLE_TYPE=dos | + | |
- | E: ID_PART_TABLE_UUID=2d923156 | + | |
- | E: ID_REVISION=1.0 | + | |
- | E: ID_SERIAL=VBOX_HARDDISK_VB823e2981-6120fc97 | + | |
- | E: ID_SERIAL_SHORT=VB823e2981-6120fc97 | + | |
- | E: ID_TYPE=disk | + | |
- | E: MAJOR=8 | + | |
- | E: MINOR=0 | + | |
- | E: SUBSYSTEM=block | + | |
- | E: TAGS=: | + | |
- | E: USEC_INITIALIZED=9411 | + | |
</ | </ | ||
- | ===Les options de la commande=== | + | Vérifiez |
- | + | ||
- | Les options de la commande udevadm sont : | + | |
< | < | ||
- | root@debian8:~# udevadm | + | root@debian11:~# ls /lib/x86_64-linux-gnu/ |
- | Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS] | + | pam_pwquality.so |
- | info query sysfs or the udev database | + | |
- | trigger | + | |
- | settle | + | |
- | control | + | |
- | monitor | + | |
- | hwdb | + | |
- | test test an event run | + | |
- | test-builtin test a built-in command | + | |
- | + | ||
- | root@debian8: | + | |
- | Usage: udevadm info [OPTIONS] [DEVPATH|FILE] | + | |
- | -q, | + | |
- | name name of device node | + | |
- | symlink | + | |
- | path sys device path | + | |
- | property | + | |
- | all all values | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | of parent devices | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | --version | + | |
- | | + | |
</ | </ | ||
- | =====Système de fichiers /sys===== | + | L' |
- | + | ||
- | Le système de fichiers virtuel **/ | + | |
- | + | ||
- | Saisissez la commande suivante | + | |
< | < | ||
- | root@debian8:~# ls -l /sys | + | root@debian11:~# ls -l /etc/ |
- | total 0 | + | -rw-r--r-- 1 root root 2674 Dec 17 2020 / |
- | drwxr-xr-x 2 root root 0 Nov 2 14:01 block | + | |
- | drwxr-xr-x 24 root root 0 Nov 2 14:01 bus | + | |
- | drwxr-xr-x 42 root root 0 Nov 2 14:01 class | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x | + | |
- | drwxr-xr-x 105 root root 0 Nov 2 14:01 module | + | |
- | drwxr-xr-x | + | |
</ | </ | ||
- | Chaque répertoire contient des informations : | + | Afin de mettre en place une politique |
- | + | ||
- | * **block** | + | |
- | * contient des informations sur les périphériques bloc | + | |
- | * **bus** | + | |
- | * contient des informations sur les bus de données | + | |
- | * **class** | + | |
- | * contient des informations sur des classes | + | |
- | * **devices** | + | |
- | * contient des informations sur la position des périphériques sur les bus | + | |
- | * **firmware** | + | |
- | * contient, entre autre, des informations sur l' | + | |
- | * **module** | + | |
- | * contient des informations sur les modules du noyau | + | |
- | * **power** | + | |
- | * contient des informations sur la gestion | + | |
- | * **fs** | + | |
- | * contient des informations sur les systèmes de fichiers | + | |
- | + | ||
- | Pour illustrer ceci, saisissez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | root@debian8: | + | |
- | 19529728 | + | |
- | </ | + | |
- | + | ||
- | Ce chiffre correspond aux nombre | + | |
- | + | ||
- | =====Limitation des ressources===== | + | |
- | + | ||
- | ====Ulimit==== | + | |
- | + | ||
- | Les ressources disponibles aux utilisateurs peuvent être limitées par l' | + | |
- | + | ||
- | La commande **ulimit** gère deux types de limite, la limite //hard// en utilisant l' | + | |
- | + | ||
- | La limite //soft// est la limite imposée à l' | + | |
- | + | ||
- | L' | + | |
< | < | ||
- | root@debian8:~# cat / | + | root@debian11:~# vi / |
- | # / | + | root@debian11: |
+ | # Configuration for systemwide password quality limits | ||
+ | # Defaults: | ||
# | # | ||
- | #Each line describes a limit for a user in the form: | + | # Number of characters |
+ | # old password. | ||
+ | # difok = 1 | ||
# | # | ||
- | #< | + | # Minimum acceptable size for the new password (plus one if |
+ | # credits are not disabled which is the default). (See pam_cracklib manual.) | ||
+ | # Cannot be set to lower value than 6. | ||
+ | minlen = 8 | ||
# | # | ||
- | #Where: | + | # The maximum credit |
- | #< | + | # it is the minimum number of digits in the new password. |
- | # - a user name | + | dcredit = -2 |
- | # - a group name, with @group syntax | + | |
- | # - the wildcard *, for default entry | + | |
- | # - the wildcard %, can be also used with %group syntax, | + | |
- | # for maxlogin limit | + | |
- | # - NOTE: group and wildcard limits are not applied to root. | + | |
- | # To apply a limit to the root user, < | + | |
- | # | + | |
# | # | ||
- | #< | + | # The maximum credit for having uppercase characters in the new password. |
- | # - " | + | # If less than 0 it is the minimum number of uppercase characters in the new |
- | # - " | + | # password. |
+ | ucredit = -1 | ||
# | # | ||
- | #< | + | # The maximum |
- | # - core - limits the core file size (KB) | + | # If less than 0 it is the minimum |
- | # - data - max data size (KB) | + | # password. |
- | # - fsize - maximum | + | lcredit = -1 |
- | # - memlock - max locked-in-memory address space (KB) | + | |
- | # - nofile - max number of open files | + | |
- | # - rss - max resident set size (KB) | + | |
- | # - stack - max stack size (KB) | + | |
- | # - cpu - max CPU time (MIN) | + | |
- | # - nproc - max number of processes | + | |
- | # - as - address space limit (KB) | + | |
- | # - maxlogins - max number of logins for this user | + | |
- | # - maxsyslogins - max number of logins on the system | + | |
- | # - priority - the priority to run user process with | + | |
- | # - locks - max number of file locks the user can hold | + | |
- | # - sigpending - max number of pending signals | + | |
- | # - msgqueue - max memory used by POSIX message queues (bytes) | + | |
- | # - nice - max nice priority allowed to raise to values: [-20, 19] | + | |
- | # - rtprio - max realtime priority | + | |
- | # - chroot - change root to directory (Debian-specific) | + | |
# | # | ||
- | #< | + | # The maximum credit for having other characters in the new password. |
+ | # If less than 0 it is the minimum number of other characters in the new | ||
+ | # password. | ||
+ | ocredit = -1 | ||
# | # | ||
- | + | # The minimum number of required classes of characters for the new | |
- | #* | + | # password (digits, uppercase, lowercase, others). |
- | #root hard core 100000 | + | minclass = 4 |
- | #* | + | # |
- | #@student | + | # The maximum number of allowed consecutive same characters in the new password. |
- | #@faculty | + | # The check is disabled if the value is 0. |
- | #@faculty | + | # maxrepeat = 0 |
- | #ftp | + | # |
- | #ftp | + | # The maximum number of allowed consecutive characters of the same class in the |
- | #@student | + | # new password. |
- | + | # The check is disabled if the value is 0. | |
- | # End of file | + | # maxclassrepeat = 0 |
+ | # | ||
+ | # Whether to check for the words from the passwd entry GECOS string of the user. | ||
+ | # The check is enabled if the value is not 0. | ||
+ | gecoscheck = 1 | ||
+ | # | ||
+ | # Whether to check for the words from the cracklib dictionary. | ||
+ | # The check is enabled if the value is not 0. | ||
+ | dictcheck = 1 | ||
+ | # | ||
+ | # Whether to check if it contains the user name in some form. | ||
+ | # The check is enabled if the value is not 0. | ||
+ | usercheck = 1 | ||
+ | # | ||
+ | # Length | ||
+ | # The check is enabled if the value is greater than 0 and usercheck is enabled. | ||
+ | # usersubstr = 0 | ||
+ | # | ||
+ | # Whether the check is enforced by the PAM module and possibly other | ||
+ | # applications. | ||
+ | # The new password is rejected if it fails the check and the value is not 0. | ||
+ | enforcing = 1 | ||
+ | # | ||
+ | # Path to the cracklib dictionaries. Default is to use the cracklib default. | ||
+ | # dictpath = | ||
+ | # | ||
+ | # Prompt user at most N times before returning with error. The default is 1. | ||
+ | # retry = 3 | ||
+ | # | ||
+ | # Enforces pwquality checks on the root user password. | ||
+ | # Enabled if the option is present. | ||
+ | # enforce_for_root | ||
+ | # | ||
+ | # Skip testing the password quality for users that are not present in the | ||
+ | # / | ||
+ | # Enabled if the option is present. | ||
+ | # local_users_only | ||
</ | </ | ||
- | <WRAP center round important> | + | =====LAB #3 - su et su - ===== |
- | **Important** : La valeur de la limite peut être un **nombre** ou le mot **unlimited**. | + | |
- | </ | + | |
- | Par exemple, si root inscrit les deux ligne suivantes dans le fichier / | + | Vous allez maintenant devenir **fenestros2**, d' |
- | + | ||
- | < | + | |
- | ... | + | |
- | trainee | + | |
- | trainee | + | |
- | ... | + | |
- | </ | + | |
- | la limite du nombre | + | Contrôlez votre répertoire courant |
< | < | ||
- | $ ulimit -n 4096 | + | root@debian11: |
+ | /root | ||
</ | </ | ||
- | Pour consulter la liste des limites actuelles, il convient d' | + | Pour devenir |
< | < | ||
- | root@debian8:~# ulimit -a | + | root@debian11:~# su fenestros2 |
- | core file size (blocks, -c) 0 | + | |
- | data seg size | + | |
- | scheduling priority | + | |
- | file size | + | |
- | pending signals | + | |
- | max locked memory | + | |
- | max memory size | + | |
- | open files (-n) 65536 | + | |
- | pipe size (512 bytes, -p) 8 | + | |
- | POSIX message queues | + | |
- | real-time priority | + | |
- | stack size (kbytes, -s) 8192 | + | |
- | cpu time | + | |
- | max user processes | + | |
- | virtual memory | + | |
- | file locks (-x) unlimited | + | |
</ | </ | ||
- | ====Options | + | Contrôlez votre répertoire courant |
- | + | ||
- | Les options de **ulimit** sont : | + | |
< | < | ||
- | root@debian8: | + | $ pwd |
- | -su: ulimit: --: invalid option | + | /root |
- | ulimit: usage: ulimit [-SHabcdefilmnpqrstuvxT] [limit] | + | |
- | root@debian8:~# help ulimit | + | |
- | ulimit: ulimit [-SHabcdefilmnpqrstuvxT] [limit] | + | |
- | Modify shell resource limits. | + | |
- | + | ||
- | Provides control over the resources available to the shell and processes | + | |
- | it creates, on systems that allow such control. | + | |
- | + | ||
- | Options: | + | |
- | -S use the `soft' resource limit | + | |
- | -H use the `hard' resource limit | + | |
- | -a all current limits are reported | + | |
- | -b the socket buffer size | + | |
- | -c the maximum size of core files created | + | |
- | -d the maximum size of a process' | + | |
- | -e the maximum scheduling priority (`nice' | + | |
- | -f the maximum size of files written by the shell and its children | + | |
- | -i the maximum number of pending signals | + | |
- | -l the maximum size a process may lock into memory | + | |
- | -m the maximum resident set size | + | |
- | -n the maximum number of open file descriptors | + | |
- | -p the pipe buffer size | + | |
- | -q the maximum number of bytes in POSIX message queues | + | |
- | -r the maximum real-time scheduling priority | + | |
- | -s the maximum stack size | + | |
- | -t the maximum amount of cpu time in seconds | + | |
- | -u the maximum number of user processes | + | |
- | -v the size of virtual memory | + | |
- | -x the maximum number of file locks | + | |
- | -T the maximum number of threads | + | |
- | + | ||
- | Not all options are available on all platforms. | + | |
- | + | ||
- | If LIMIT is given, it is the new value of the specified resource; the | + | |
- | special LIMIT values `soft', | + | |
- | current soft limit, the current hard limit, and no limit, respectively. | + | |
- | Otherwise, the current value of the specified resource is printed. | + | |
- | no option is given, then -f is assumed. | + | |
- | + | ||
- | Values are in 1024-byte increments, except for -t, which is in seconds, | + | |
- | -p, which is in increments of 512 bytes, and -u, which is an unscaled | + | |
- | number of processes. | + | |
- | + | ||
- | Exit Status: | + | |
- | Returns success unless an invalid option is supplied or an error occurs. | + | |
</ | </ | ||
- | ====Groupes | + | Vous noterez que vous êtes toujours dans le répertoire **/root**. Ceci indique que vous avez gardé l' |
- | Les **Groupes de Contrôles** (//Control Groups//) aussi appelés **CGroups**, | + | <WRAP center round important> |
- | + | **Important** : L'environnement | |
- | Les groupes | + | </WRAP> |
- | + | ||
- | Ces hiérarchies multiples et séparés sont necéssaires parce que chaque hiérarchie est attaché à un ou plusieurs **sous-système(s)** aussi appelés des **Contrôleurs de Ressources** ou simplement des **Contrôleurs**. Les contrôleurs disponibles sous Debian 8 sont : | + | |
- | + | ||
- | * **blkio** - utilisé pour établir des limites sur l' | + | |
- | * **cpu** - utilisé pour fournir aux tâches des groupes de contrôle accès au CPU grâce au planificateur, | + | |
- | * **cpuacct** - utilisé pour produire des rapports automatiques sur les ressources CPU utilisées par les tâches dans un groupe de contrôle, | + | |
- | * **cpuset** - utilisé pour assigner des CPU individuels sur un système multicoeur et des noeuds de mémoire à des tâches dans un groupe de contrôle, | + | |
- | * **devices** - utilisé pour autoriser ou pour refuser l' | + | |
- | * **freezer** - utilisé pour suspendre ou pour réactiver les tâches dans un groupe de contrôle, | + | |
- | * **memory** - utilisé pour établir les limites d' | + | |
- | * **net_cls** - utilisé pour repèrer les paquets réseau avec un identifiant de classe (// | + | |
- | * **perf_event** | + | |
- | * **hugetlb** - utilisé pour limiter des ressources sur des pages de mémoire virtuelle de grande taille. | + | |
- | Sous Debian 8, les Cgroups ne sont pas installés par défaut | + | Saisissez la commande suivante pour redevenir **root** |
< | < | ||
- | root@debian8:~# apt-get install cgroup-bin cgroup-tools | + | $ exit |
- | Reading package lists... Done | + | root@debian11:~# |
- | Building dependency tree | + | |
- | Reading state information... Done | + | |
- | The following extra packages will be installed: | + | |
- | libcgroup1 | + | |
- | The following NEW packages will be installed: | + | |
- | cgroup-bin cgroup-tools libcgroup1 | + | |
- | 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded. | + | |
- | Need to get 119 kB of archives. | + | |
- | After this operation, 359 kB of additional disk space will be used. | + | |
- | Do you want to continue? [Y/n] y | + | |
- | Get:1 http:// | + | |
- | Get:2 http:// | + | |
- | Get:3 http:// | + | |
- | Fetched 119 kB in 0s (130 kB/s) | + | |
- | Selecting previously unselected package libcgroup1: | + | |
- | (Reading database ... 86206 files and directories currently installed.) | + | |
- | Preparing to unpack .../ | + | |
- | Unpacking libcgroup1: | + | |
- | Selecting previously unselected package cgroup-tools. | + | |
- | Preparing to unpack .../ | + | |
- | Unpacking cgroup-tools (0.41-6) ... | + | |
- | Selecting previously unselected package cgroup-bin. | + | |
- | Preparing to unpack .../ | + | |
- | Unpacking cgroup-bin (0.41-6) ... | + | |
- | Processing triggers for man-db (2.7.0.2-5) ... | + | |
- | Setting up libcgroup1: | + | |
- | Setting up cgroup-tools (0.41-6) ... | + | |
- | Setting up cgroup-bin (0.41-6) ... | + | |
- | Processing triggers for libc-bin (2.19-18+deb8u4) ... | + | |
</ | </ | ||
- | Pour visualiser les hiérarchies, | + | Saisissez |
< | < | ||
- | root@debian8:~# lssubsys | + | root@debian11:~# su - fenestros2 |
- | memory | + | </ |
- | cpuset / | + | |
- | cpu,cpuacct / | + | |
- | devices / | + | |
- | freezer / | + | |
- | net_cls, | + | |
- | blkio / | + | |
- | perf_event / | + | |
- | </ | + | |
- | Sous Debian 8, **Systemd** organise les processus dans chaque CGroup. Par exemple tous les processus démarrés par le serveur Apache se trouveront dans le même CGroup, y compris les scripts CGI. Ceci implique que la gestion des ressources en utilisant des hiérarchies est couplé avec l' | + | Contrôlez votre répertoire courant |
- | + | ||
- | En haut de l' | + | |
- | + | ||
- | * le **system.slice** - l' | + | |
- | * le **user.slice** - l' | + | |
- | * le **machine.slice** - l' | + | |
- | + | ||
- | En dessous des tranches peuvent se trouver : | + | |
- | + | ||
- | * des **scopes** - des processus crées par **fork**, | + | |
- | * des **services** - des processus créés par une **Unité**. | + | |
- | + | ||
- | Les slices peuvent être visualisés avec la commande suivante | + | |
< | < | ||
- | root@debian8: | + | $ pwd |
- | UNIT | + | / |
- | -.slice | + | </ |
- | system-getty.slice loaded active active system-getty.slice | + | |
- | system-ifup.slice | + | |
- | system.slice | + | |
- | user-1000.slice | + | |
- | user.slice | + | |
- | LOAD = Reflects whether the unit definition was properly loaded. | + | Vous noterez que vous êtes maintenant dans le répertoire **/ |
- | ACTIVE = The high-level unit activation state, i.e. generalization of SUB. | + | |
- | SUB = The low-level unit activation state, values depend on unit type. | + | |
- | 6 loaded units listed. Pass --all to see loaded but inactive units, too. | + | Saisissez |
- | To show all installed unit files use ' | + | |
- | </ | + | |
- | + | ||
- | L' | + | |
< | < | ||
- | root@debian8:~# systemd-cgls | + | $ exit |
- | ├─1 / | + | root@debian11:~# |
- | ├─system.slice | + | |
- | │ ├─avahi-daemon.service | + | |
- | │ │ ├─504 avahi-daemon: | + | |
- | │ │ └─514 avahi-daemon: | + | |
- | │ ├─dbus.service | + | |
- | │ │ └─505 / | + | |
- | │ ├─ModemManager.service | + | |
- | │ │ └─483 / | + | |
- | │ ├─cron.service | + | |
- | │ │ └─494 / | + | |
- | │ ├─nfs-common.service | + | |
- | │ │ ├─466 / | + | |
- | │ │ └─480 / | + | |
- | │ ├─exim4.service | + | |
- | │ │ └─817 / | + | |
- | │ ├─networking.service | + | |
- | │ │ └─410 dhclient -v -pf / | + | |
- | │ ├─atd.service | + | |
- | │ │ └─497 / | + | |
- | │ ├─systemd-journald.service | + | |
- | │ │ └─141 / | + | |
- | │ ├─upower.service | + | |
- | │ │ └─1907 / | + | |
- | │ ├─packagekit.service | + | |
- | │ │ └─8243 / | + | |
- | │ ├─ssh.service | + | |
- | │ │ └─493 / | + | |
- | │ ├─systemd-logind.service | + | |
- | │ │ └─500 / | + | |
- | │ ├─system-getty.slice | + | |
- | │ │ └─getty@tty1.service | + | |
- | │ │ | + | |
- | │ ├─systemd-udevd.service | + | |
- | │ │ └─153 / | + | |
- | │ ├─polkitd.service | + | |
- | │ │ └─767 / | + | |
- | │ ├─rpcbind.service | + | |
- | │ │ └─457 / | + | |
- | │ ├─NetworkManager.service | + | |
- | │ │ └─495 / | + | |
- | │ ├─simplegateway.service | + | |
- | │ │ ├─ | + | |
- | │ │ ├─ 1728 / | + | |
- | │ │ ├─ 1826 / | + | |
- | │ │ ├─21051 /bin/sh / | + | |
- | │ │ └─21098 sleep 1 | + | |
- | │ ├─rsyslog.service | + | |
- | │ │ └─559 / | + | |
- | │ └─acpid.service | + | |
- | │ | + | |
- | └─user.slice | + | |
- | └─user-1000.slice | + | |
- | ├─user@1000.service | + | |
- | │ ├─15440 / | + | |
- | │ └─15441 (sd-pam) | + | |
- | ├─session-10.scope | + | |
- | │ ├─21923 sshd: trainee [priv] | + | |
- | │ ├─21957 sshd: trainee@pts/ | + | |
- | │ ├─21958 -bash | + | |
- | │ ├─21999 su - | + | |
- | │ └─22027 -su | + | |
- | └─session-13.scope | + | |
- | ├─11749 sshd: trainee [priv] | + | |
- | ├─11819 sshd: trainee@pts/ | + | |
- | ├─11820 -bash | + | |
- | ├─15165 su - | + | |
- | ├─15193 -su | + | |
- | ├─21101 systemd-cgls | + | |
- | └─21112 systemd-cgls | + | |
</ | </ | ||
- | |||
- | En utilisant Systemd, plusieurs ressources peuvent être limitées : | ||
- | |||
- | * **CPUShares** - par défault 1024, | ||
- | * **MemoryLimit** - limite exprimée en Mo ou en Go. Pas de valeur par défaut, | ||
- | * **BlockIOWeight** - valeur entre 10 et 1000. Pas de valeur par défaut, | ||
- | * **StartupCPUShares** - comme CPUShares mais uniquement appliqué pendant le démarrage, | ||
- | * **StartupBlockIOWeight** - comme BlockIOWeight mais uniquement appliqué pendant le démarrage, | ||
- | * **CPUQuota** - utilisé pour limiter le temps CPU, même quand le système ne fait rien. | ||
<WRAP center round important> | <WRAP center round important> | ||
- | **Important** : Consultez le manuel systemd.resource-control(5) pour voir les paramètres CGroup qui peuvent être passés à systemctl. | + | **Important** : Notez que **root** peut devenir n' |
</ | </ | ||
- | ===LAB #1 - Travailler avec les cgroups sous Debian 8=== | + | =====LAB #4 - sudo===== |
- | Créez | + | La commande **sudo** permet à un utilisateur autorisé d' |
+ | |||
+ | Saisissez la commande suivante | ||
< | < | ||
- | root@debian8:~# vi /lib/systemd/system/ | + | root@debian11:~# cat /etc/sudoers |
- | root@debian8:~# cat /lib/systemd/ | + | # |
- | [Unit] | + | # This file MUST be edited with the ' |
- | Description=The foo service that does nothing useful | + | # |
- | After=remote-fs.target nss-lookup.target | + | # Please consider adding local content in /etc/sudoers.d/ instead of |
+ | # directly modifying this file. | ||
+ | # | ||
+ | # See the man page for details on how to write a sudoers file. | ||
+ | # | ||
+ | Defaults | ||
+ | Defaults | ||
+ | Defaults | ||
- | [Service] | + | # Host alias specification |
- | ExecStart=/ | + | |
- | ExecStop=/ | + | |
- | [Install] | + | # User alias specification |
- | WantedBy=multi-user.target | + | |
- | root@debian8: | + | # Cmnd alias specification |
- | ● foo.service - The foo service that does nothing useful | + | |
- | | + | |
- | | + | |
- | </ | + | |
- | Démarrez et activez le service | + | # User privilege specification |
+ | root ALL=(ALL:ALL) ALL | ||
- | < | + | # Allow members of group sudo to execute any command |
- | root@debian8: | + | %sudo |
- | root@debian8: | + | |
- | Created symlink from / | + | # See sudoers(5) for more information on " |
- | root@debian8: | + | |
- | ● foo.service - The foo service that does nothing useful | + | @includedir |
- | Loaded: loaded (/ | + | |
- | Active: active | + | |
- | Main PID: 25509 (sha1sum) | + | |
- | CGroup: | + | |
- | | + | |
</ | </ | ||
- | Notez que notre service a été placé dans la tranche | + | <WRAP center round important> |
+ | **Important** : Notez la présence de la ligne **%sudo | ||
+ | </ | ||
+ | |||
+ | Devenez l' | ||
< | < | ||
- | root@debian8:~# systemctl show -p Slice foo.service | + | root@debian11:~# exit |
- | Slice=system.slice | + | logout |
+ | trainee@debian11: | ||
</ | </ | ||
- | Utilisez ps pour voir le pourcentage du CPU utilisé par ce service | + | Saisissez la commande suivante |
< | < | ||
- | root@debian8:~# ps -p 25509 -o pid, | + | trainee@debian11:~$ sudo su - |
- | PID COMMAND | + | |
- | 25509 sha1sum | + | |
- | </ | + | |
- | Fixez maintenant la valeur de CPUShares pour ce service à 250 : | + | We trust you have received the usual lecture from the local System |
+ | Administrator. It usually boils down to these three things: | ||
- | < | + | #1) Respect the privacy of others. |
- | root@debian8: | + | #2) Think before you type. |
+ | #3) With great power comes great responsibility. | ||
+ | |||
+ | [sudo] password for trainee: | ||
</ | </ | ||
- | Cette limite est permenante et a été inscrite dans le fichier | + | Saisissez |
< | < | ||
- | root@debian8:~# ls / | + | [sudo] password for trainee: trainee |
- | 50-CPUShares.conf | + | trainee is not in the sudoers file. This incident will be reported. |
- | root@debian8: | + | |
- | [Service] | + | |
- | CPUShares=250 | + | |
</ | </ | ||
<WRAP center round important> | <WRAP center round important> | ||
- | **Important** : En utilisant | + | **Important** : Notez que la commande a échoué car l'utilisateur |
</ | </ | ||
- | Appliquez cette modification en rechargeant systemd et en re-démarrant | + | Mettez maintenant l' |
< | < | ||
- | root@debian8:~# systemctl daemon-reload | + | trainee@debian11:~$ su - |
- | root@debian8:~# systemctl restart foo.service | + | Password: fenestros |
- | </ | + | |
- | Vérifiez maintenant que la limite a été appliquée | + | root@debian11:~# usermod -aG sudo trainee |
- | < | + | root@debian11:~# groups trainee |
- | root@debian8:~# cat / | + | trainee |
- | 250 | + | |
- | root@debian8:~# systemctl show -p MainPID foo.service | + | root@debian11:~# exit |
- | MainPID=26975 | + | logout |
- | root@debian8:~# cat / | + | |
- | 3: | + | |
- | 1: | + | |
</ | </ | ||
- | Créez maintenant le service | + | Constatez que vous ne faites pas parti du groupe |
< | < | ||
- | root@debian8:~# vi / | + | trainee@debian11:~$ groups |
- | root@debian8: | + | trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner |
- | [Unit] | + | |
- | Description=The bar service that does nothing useful | + | |
- | After=remote-fs.target nss-lookup.target | + | |
- | + | ||
- | [Service] | + | |
- | ExecStart=/ | + | |
- | ExecStop=/ | + | |
- | + | ||
- | [Install] | + | |
- | WantedBy=multi-user.target | + | |
</ | </ | ||
- | Fixez maintenant la limite de CPUShares pour ce service à 2000 : | + | Rejoignez le groupe **sudo** |
< | < | ||
- | root@debian8:~# systemctl set-property bar.service CPUShares=2000 | + | trainee@debian11:~$ newgrp sudo |
- | Failed to set unit properties on bar.service: | + | |
- | root@debian8: | + | |
- | root@debian8: | + | |
- | Created symlink from / | + | |
- | root@debian8: | + | |
- | </ | + | |
- | Appliquez la limite : | + | trainee@debian11:~$ groups |
- | + | sudo cdrom floppy audio dip video plugdev netdev lpadmin scanner trainee | |
- | < | + | |
- | root@debian8:~# systemctl daemon-reload | + | |
- | root@debian8: | + | |
- | root@debian8: | + | |
- | ● bar.service - The bar service that does nothing useful | + | |
- | | + | |
- | Drop-In: / | + | |
- | | + | |
- | | + | |
- | Process: 28993 ExecStop=/ | + | |
- | Main PID: 28995 (md5sum) | + | |
- | | + | |
- | └─28995 / | + | |
</ | </ | ||
- | Re-démarrer les services foo et bar : | + | Essayez de nouveau la commande sudo : |
< | < | ||
- | root@debian8:~# systemctl restart foo.service | + | trainee@debian11:~$ sudo su - |
- | root@debian8: | + | [sudo] password for trainee: trainee |
- | ● foo.service | + | root@debian11:~# |
- | Loaded: loaded (/ | + | |
- | Drop-In: / | + | |
- | | + | |
- | | + | |
- | Process: 29351 ExecStop=/ | + | |
- | Main PID: 29353 (sha1sum) | + | |
- | | + | |
- | | + | |
- | root@debian8:~# systemctl restart bar.service | + | |
- | root@debian8: | + | |
- | ● bar.service - The bar service that does nothing useful | + | |
- | | + | |
- | Drop-In: / | + | |
- | | + | |
- | | + | |
- | Process: 29483 ExecStop=/ | + | |
- | Main PID: 29485 (md5sum) | + | |
- | | + | |
- | | + | |
</ | </ | ||
- | Utilisez ps pour voir le pourcentage du CPU utilisé par les deux services | + | <WRAP center round important> |
+ | **Important** | ||
+ | </ | ||
- | < | ||
- | root@debian8: | ||
- | PID COMMAND | ||
- | 29353 sha1sum | ||
- | 29485 md5sum | ||
- | </ | ||
- | |||
- | ----- | ||
- | < | ||
- | <div align=" | ||
- | Copyright © 2020 Hugh Norris.< | ||
- | </ | ||
- | </ | ||
----- | ----- | ||
+ | Copyright © 2024 Hugh Norris. |