Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:lpic:11:500:l104 [2023/06/09 12:05] – admin | elearning:workbooks:lpic:11:500:l104 [2024/04/05 08:03] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2023.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
Ligne 2936: | Ligne 2936: | ||
</ | </ | ||
- | ----- | + | =====Gestion des Droits===== |
- | Copyright © 2023 Hugh Norris. | + | Dans sa conception de base, Linux utilise une approche sécurité de type **DAC**. Cette approche est maintenue dans la mise en place et l' |
+ | |||
+ | ^ Type de Sécurité | ||
+ | | DAC | // | ||
+ | |||
+ | ====Préparation==== | ||
+ | |||
+ | Dans votre répertoire personnel, créez un fichier tux.jpg grâce à la commande **touch**: | ||
+ | |||
+ | $ touch tux.jpg [Entrée] | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ pwd | ||
+ | / | ||
+ | [trainee@centos7 ~]$ touch tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-rw-r--. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que le fichier créé est un fichier **texte**. En effet, Linux ne tient pas compte de l' | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Simples==== | ||
+ | |||
+ | Les autorisations ou droits d’accès en Linux sont communiqués comme suit : | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | ou r = lecture, w = écriture et x = exécutable | ||
+ | |||
+ | Dans chaque inode est stocké le numéro de l’utilisateur à qui appartient le fichier concerné ainsi que le numéro du groupe. Quand le fichier est ouvert le système compare le numéro de l’utilisateur (UID) avec le numéro de l’utilisateur stocké dans l’inode ( Utilisateur de Référence ). Si ces deux numéros sont identiques, l’utilisateur obtient les droits du propriétaire du fichier. Si les numéros diffèrent, le système vérifie si l’utilisateur est dans le groupe référencé dans l’inode. Si oui, l’utilisateur aura les droits spécifiés pour le groupe. Si aucune condition n’est remplie, l’utilisateur se voit attribuer les droits des «autres». | ||
+ | |||
+ | Les droits pour les répertoires sont légèrement différents : | ||
+ | |||
+ | ^ r | Les éléments du répertoire sont accessible en lecture ( lister ) | | ||
+ | ^ w | Les éléments du répertoire sont modifiables ( création et suppression ). | | ||
+ | ^ x | Le nom du répertoire peut apparaître dans un chemin d' | ||
+ | |||
+ | ===La Modification des Droits=== | ||
+ | |||
+ | == La Commande chmod== | ||
+ | |||
+ | ==Mode Symbolique== | ||
+ | |||
+ | Afin de modifier les droits d’accès aux fichiers, on utilise la commande chmod dont le syntaxe est le suivant : | ||
+ | |||
+ | chmod [ -R ] catégorie opérateur permissions nom_du_fichier | ||
+ | |||
+ | ou | ||
+ | |||
+ | chmod [ -R ] ugoa +-= rwxXst nom_du_fichier | ||
+ | |||
+ | où | ||
+ | |||
+ | ^ u | user | | ||
+ | ^ g | group | | ||
+ | ^ o | other | | ||
+ | ^ a | all | | ||
+ | ^ + | autorise un accès | | ||
+ | ^ - | interdit | ||
+ | ^ = | autorise exclusivement l’accès indiqué | | ||
+ | ^ r | read | | ||
+ | ^ w | write | | ||
+ | ^ x | execute | | ||
+ | ^ X | exécution si la cible est un répertoire ou si c'est un\\ fichier est déjà exécutable pour une des // | ||
+ | ^ s | SUID/SGID bit | | ||
+ | ^ t | sticky bit | | ||
+ | |||
+ | par exemple : | ||
+ | |||
+ | $ chmod o+w tux.jpg [Entrée] | ||
+ | |||
+ | donnera aux autres l’accès en écriture sur le fichier tux.jpg : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod o+w tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-rw-rw-. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | Tandis que : | ||
+ | |||
+ | $ chmod ug-w tux.jpg [Entrée] | ||
+ | |||
+ | ôtera les droit d’accès en écriture pour l’utilisateur et le groupe : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod ug-w tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -r--r--rw-. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Seul le propriétaire du fichier ou root peuvent modifier les permissions. | ||
+ | </ | ||
+ | |||
+ | ==Mode Octal== | ||
+ | |||
+ | La commande chmod peut également être utilisée avec une représentation octale ( base de 8 ). Les valeurs octales des droits d’accès sont : | ||
+ | |||
+ | {{free: | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Ainsi les droits rwx rwx rwx correspondent à un chiffre de 777. | ||
+ | </ | ||
+ | |||
+ | La commande chmod prend donc la forme suivante: | ||
+ | |||
+ | chmod [ -R ] mode_octal nom_fichier | ||
+ | |||
+ | La commande suivante : | ||
+ | |||
+ | $ chmod 644 tux.jpg [Entrée] | ||
+ | |||
+ | Correspond donc à l’attribution des droits : rw- r-- r-- | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod 644 tux.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 trainee trainee | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Les droits d’accès par défaut lors de la création d’un objet sont : | ||
+ | ^ Répertoires | rwx rwx rwx | 777 | | ||
+ | ^ Fichier normal | rw– rw– rw- | 666 | | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ chmod --help | ||
+ | Usage: chmod [OPTION]... MODE[, | ||
+ | or: chmod [OPTION]... OCTAL-MODE FILE... | ||
+ | or: chmod [OPTION]... --reference=RFILE FILE... | ||
+ | Change the mode of each FILE to MODE. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | -R, --recursive | ||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Each MODE is of the form ' | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ==La Commande umask== | ||
+ | |||
+ | L’utilisateur peut changer sa masque de permissions défaut lors de la création d’objets en utilisant la commande umask. | ||
+ | |||
+ | La valeur par défaut de l' | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ umask | ||
+ | 0002 | ||
+ | [trainee@centos7 ~]$ su - | ||
+ | Password: fenestros | ||
+ | Last login: Tue Oct 20 05:47:19 CEST 2015 on pts/0 | ||
+ | [root@centos7 ~]# umask | ||
+ | 0022 | ||
+ | [root@centos7 ~]# exit | ||
+ | logout | ||
+ | </ | ||
+ | |||
+ | Par exemple dans le cas où l’utilisateur souhaite que les fichiers créés dans le futur comportent des droits d’écriture et de lecture pour l’utilisateur mais uniquement des droits de lecture pour le groupe et pour les autres, il utiliserait la commande : | ||
+ | |||
+ | $ umask 022 [Entrée] | ||
+ | |||
+ | avant de créer son fichier. | ||
+ | |||
+ | <WRAP center round important> | ||
+ | umask sert à enlever des droits des droits maximaux : | ||
+ | ^ Masque maximum lors de la création d’un fichier | rw- rw- rw- | 666 | | ||
+ | ^ Droits à retirer | --- -w- -w- | 022 | | ||
+ | ^ Résultat | rw- r-- r-- | 644 | | ||
+ | </ | ||
+ | |||
+ | Dans l' | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ umask 044 | ||
+ | [trainee@centos7 ~]$ touch tux1.jpg | ||
+ | [trainee@centos7 ~]$ ls -l | grep tux1.jpg | ||
+ | -rw--w--w-. 1 trainee trainee | ||
+ | [trainee@centos7 ~]$ umask 002 | ||
+ | [trainee@centos7 ~]$ umask | ||
+ | 0002 | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ help umask | ||
+ | umask: umask [-p] [-S] [mode] | ||
+ | Display or set file mode mask. | ||
+ | |||
+ | Sets the user file-creation mask to MODE. If MODE is omitted, prints | ||
+ | the current value of the mask. | ||
+ | |||
+ | If MODE begins with a digit, it is interpreted as an octal number; | ||
+ | otherwise it is a symbolic mode string like that accepted by chmod(1). | ||
+ | |||
+ | Options: | ||
+ | -p if MODE is omitted, output in a form that may be reused as input | ||
+ | -S makes the output symbolic; otherwise an octal number is output | ||
+ | |||
+ | Exit Status: | ||
+ | Returns success unless MODE is invalid or an invalid option is given. | ||
+ | </ | ||
+ | |||
+ | ===Modifier le propriétaire ou le groupe=== | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Le changement de propriétaire d’un fichier se fait uniquement par l' | ||
+ | </ | ||
+ | |||
+ | ==La Commande chown== | ||
+ | |||
+ | Dans le cas du fichier tux.jpg appartenant à trainee, root peut changer le propriétaire de trainee à root avec la commande suivante : | ||
+ | |||
+ | # chown root tux.jpg [Entrée] | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ su - | ||
+ | Password: fenestros | ||
+ | Last login: Tue Oct 20 07:35:01 CEST 2015 on pts/0 | ||
+ | [root@centos7 ~]# cd / | ||
+ | [root@centos7 trainee]# chown root tux.jpg | ||
+ | [root@centos7 trainee]# ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 root trainee | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chown --help | ||
+ | Usage: chown [OPTION]... [OWNER][: | ||
+ | or: chown [OPTION]... --reference=RFILE FILE... | ||
+ | Change the owner and/or group of each FILE to OWNER and/or GROUP. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --dereference | ||
+ | the default), rather than the symbolic link itself | ||
+ | -h, --no-dereference | ||
+ | | ||
+ | | ||
+ | --from=CURRENT_OWNER: | ||
+ | | ||
+ | its current owner and/or group match those specified | ||
+ | | ||
+ | is not required for the omitted attribute | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | | ||
+ | -R, --recursive | ||
+ | |||
+ | The following options modify how a hierarchy is traversed when the -R | ||
+ | option is also specified. | ||
+ | one takes effect. | ||
+ | |||
+ | -H if a command line argument is a symbolic link | ||
+ | to a directory, traverse it | ||
+ | -L | ||
+ | | ||
+ | -P do not traverse any symbolic links (default) | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Owner is unchanged if missing. | ||
+ | to login group if implied by a ':' | ||
+ | OWNER and GROUP may be numeric as well as symbolic. | ||
+ | |||
+ | Examples: | ||
+ | chown root /u Change the owner of /u to " | ||
+ | chown root:staff /u Likewise, but also change its group to " | ||
+ | chown -hR root /u Change the owner of /u and subfiles to " | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ==La Commande chgrp== | ||
+ | |||
+ | Le même cas de figure s’applique au groupe : | ||
+ | |||
+ | # chgrp root tux.jpg [Entrée] | ||
+ | |||
+ | affectera le fichier au groupe root : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chgrp root tux.jpg | ||
+ | [root@centos7 trainee]# ls -l | grep tux.jpg | ||
+ | -rw-r--r--. 1 root root 0 Oct 20 07:21 tux.jpg | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Rappel** : Seul root peut changer le propriétaire d'un fichier. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Le droit de supprimer un fichier dépend des droits sur le répertoire dans lequel le fichier est stocké et non des droits du fichier lui-même. | ||
+ | </ | ||
+ | |||
+ | Les options de cette commande sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# chgrp --help | ||
+ | Usage: chgrp [OPTION]... GROUP FILE... | ||
+ | or: chgrp [OPTION]... --reference=RFILE FILE... | ||
+ | Change the group of each FILE to GROUP. | ||
+ | With --reference, | ||
+ | |||
+ | -c, --changes | ||
+ | -f, --silent, --quiet | ||
+ | -v, --verbose | ||
+ | --dereference | ||
+ | the default), rather than the symbolic link itself | ||
+ | -h, --no-dereference | ||
+ | | ||
+ | | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | GROUP value | ||
+ | -R, --recursive | ||
+ | |||
+ | The following options modify how a hierarchy is traversed when the -R | ||
+ | option is also specified. | ||
+ | one takes effect. | ||
+ | |||
+ | -H if a command line argument is a symbolic link | ||
+ | to a directory, traverse it | ||
+ | -L | ||
+ | | ||
+ | -P do not traverse any symbolic links (default) | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | Examples: | ||
+ | chgrp staff /u Change the group of /u to " | ||
+ | chgrp -hR staff /u Change the group of /u and subfiles to " | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | For complete documentation, | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Etendus==== | ||
+ | |||
+ | ===SUID/ | ||
+ | |||
+ | Malgré ce que vous venez de voir, dans la première des deux fenêtres ci-dessous, vous noterez que le fichier **passwd** se trouvant dans le répertoire **/etc** possède les permissions **rw- r-- r--** et qu'il appartient à **root**. Autrement dit **seul** root peut écrire dans ce fichier. Or, quand un utilisateur normal change son mot de passe, il écrit dans ce fichier. Ceci semble donc être une contradiction. | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# ls -l /etc/passwd / | ||
+ | -rw-r--r--. 1 root root 2062 Oct 19 15:38 / | ||
+ | -rwsr-xr-x. 1 root root 27832 Jun 10 2014 / | ||
+ | </ | ||
+ | |||
+ | Pour remédier à cette apparente contradiction, | ||
+ | |||
+ | * Set %%UserID%% bit ( SUID bit ) | ||
+ | * Set %%GroupID%% bit ( SGID bit ) | ||
+ | |||
+ | Quand le SUID bit est placé sur un programme, l’utilisateur qui lance ce programme se voit affecté le numéro d’utilisateur du propriétaire de ce programme et ce pour la durée de son exécution. | ||
+ | |||
+ | Dans le cas du changement de mot de passe, chaque utilisateur qui lance le programme / | ||
+ | |||
+ | La même fonction existe pour le groupe à l’aide du SGID bit. | ||
+ | |||
+ | Pour assigner les droits, vous utiliserez la commande chmod : | ||
+ | |||
+ | * chmod u+s nom_du_fichier | ||
+ | * chmod g+s nom_du_fichier | ||
+ | |||
+ | En base huit les valeurs sont les suivants : | ||
+ | |||
+ | * SUID = 4000 | ||
+ | * SGID = 2000 | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Afin d' | ||
+ | |||
+ | # find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls {} \; [Entrée] | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===Inheritance Flag=== | ||
+ | |||
+ | Le SGID bit peut également être affecté à un répertoire. De cette façon, les fichiers et répertoires créés à l' | ||
+ | |||
+ | Par exemple : | ||
+ | |||
+ | < | ||
+ | [root@centos7 trainee]# cd /tmp | ||
+ | [root@centos7 tmp]# mkdir inherit | ||
+ | [root@centos7 tmp]# chown root: | ||
+ | [root@centos7 tmp]# chmod g+s inherit | ||
+ | [root@centos7 tmp]# touch inherit/ | ||
+ | [root@centos7 tmp]# mkdir inherit/ | ||
+ | [root@centos7 tmp]# cd inherit; ls -l | ||
+ | total 0 | ||
+ | drwxr-sr-x. 2 root trainee 6 Oct 20 07:58 testrep | ||
+ | -rw-r--r--. 1 root trainee 0 Oct 20 07:58 test.txt | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** : Notez que malgré le fait que root a créé les deux objets, ceux-ci ne sont pas associés avec le groupe **root** mais avec le groupe **trainee**, | ||
+ | </ | ||
+ | |||
+ | ===Sticky bit=== | ||
+ | |||
+ | Il existe un dernier cas qui s’appelle le sticky bit. Le sticky bit est utilisé pour des répertoires ou tout le monde a tous les droits. Dans ce cas, tout le monde peut supprimer des fichiers dans le répertoire. En ajoutant le sticky bit, uniquement le propriétaire du fichier peut le supprimer. | ||
+ | |||
+ | # chmod o+t / | ||
+ | |||
+ | ou | ||
+ | |||
+ | # chmod 1777 / | ||
+ | |||
+ | Par exemple la ligne de commande: | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | ou | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | créera un répertoire **repertoire_public** dans /tmp avec les droits suivants : | ||
+ | |||
+ | < | ||
+ | [root@centos7 inherit]# mkdir / | ||
+ | [root@centos7 tmp]# ls -l | grep repertoire_public | ||
+ | drwxr-xr-t. 2 root root 6 Oct 20 07:59 repertoire_public | ||
+ | </ | ||
+ | |||
+ | ====Les Droits Unix Avancés==== | ||
+ | |||
+ | ===Les ACL=== | ||
+ | |||
+ | Au delà des droits étendus d' | ||
+ | |||
+ | Pour connaître les ACL positionnés sur un fichier, il convient d' | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | En utilisant cette commande, vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rw- | ||
+ | group:: | ||
+ | other:: | ||
+ | |||
+ | </ | ||
+ | |||
+ | Pour positionner des ACL sur un fichier, il convient d' | ||
+ | |||
+ | # setfacl --set u:: | ||
+ | |||
+ | Utilisez la commande **getfacl** pour visualiser le résultat : | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# setfacl --set u:: | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rwx | ||
+ | user: | ||
+ | group:: | ||
+ | mask::rwx | ||
+ | other:: | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Veuillez noter l' | ||
+ | </ | ||
+ | |||
+ | Regardez maintenant l' | ||
+ | |||
+ | # mkdir / | ||
+ | |||
+ | Positionnez des ACL le répertoire avec la commande **setfacl** : | ||
+ | |||
+ | # setfacl --set d: | ||
+ | |||
+ | Notez l' | ||
+ | |||
+ | Créez maintenant un fichier appelé fichier1 dans / | ||
+ | |||
+ | # touch / | ||
+ | |||
+ | Utilisez la commande **getfacl** pour visualiser le résultat : | ||
+ | |||
+ | # getfacl / | ||
+ | |||
+ | # getfacl home/ | ||
+ | |||
+ | Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# mkdir / | ||
+ | [root@centos7 tmp]# setfacl --set d: | ||
+ | [root@centos7 tmp]# touch / | ||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rwx | ||
+ | group:: | ||
+ | other:: | ||
+ | default: | ||
+ | default: | ||
+ | default: | ||
+ | |||
+ | [root@centos7 tmp]# getfacl / | ||
+ | getfacl: Removing leading '/' | ||
+ | # file: home/ | ||
+ | # owner: root | ||
+ | # group: root | ||
+ | user::r-- | ||
+ | group:: | ||
+ | other:: | ||
+ | |||
+ | </ | ||
+ | |||
+ | Notez que le fichier créé possède les ACL positionnés sur le répertoire rep1. | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | # getfacl -R --skip-base . > backup.acl [Entrée] | ||
+ | |||
+ | La restauration des ACL se fait avec la commande **setfacl** : | ||
+ | |||
+ | # setfacl --restore=backup.acl [Entrée] | ||
+ | |||
+ | Les options de la commande **getfacl** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# getfacl --help | ||
+ | getfacl 2.2.51 -- get file access control lists | ||
+ | Usage: getfacl [-aceEsRLPtpndvh] file ... | ||
+ | -a, --access | ||
+ | -d, --default | ||
+ | -c, --omit-header | ||
+ | -e, --all-effective | ||
+ | -E, --no-effective | ||
+ | -s, --skip-base | ||
+ | -R, --recursive | ||
+ | -L, --logical | ||
+ | -P, --physical | ||
+ | -t, --tabular | ||
+ | -n, --numeric | ||
+ | -p, --absolute-names | ||
+ | -v, --version | ||
+ | -h, --help | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **setfacl** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# setfacl --help | ||
+ | setfacl 2.2.51 -- set file access control lists | ||
+ | Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ... | ||
+ | -m, --modify=acl | ||
+ | -M, --modify-file=file | ||
+ | -x, --remove=acl | ||
+ | -X, --remove-file=file | ||
+ | -b, --remove-all | ||
+ | -k, --remove-default | ||
+ | --set=acl | ||
+ | --set-file=file | ||
+ | --mask | ||
+ | -n, --no-mask | ||
+ | -d, --default | ||
+ | -R, --recursive | ||
+ | -L, --logical | ||
+ | -P, --physical | ||
+ | --restore=file | ||
+ | --test | ||
+ | -v, --version | ||
+ | -h, --help | ||
+ | </ | ||
+ | |||
+ | ===Les Attributs Etendus=== | ||
+ | |||
+ | Les attributs s' | ||
+ | |||
+ | Les principaux attributs sont : | ||
+ | |||
+ | ^ Attribut ^ Description ^ | ||
+ | | a | Fichier journal - uniquement l' | ||
+ | | i | Le fichier ne peut ni être modifié, ni être détruit, ni être déplacé. Le placement d'un lien sur le fichier n'est pas permis | | ||
+ | | s | Le fichier sera physiquement détruit lors de sa suppression | | ||
+ | | D | Répertoire synchrone | | ||
+ | | S | Fichier synchrone | | ||
+ | | A | La date et l' | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Un fichier synchrone et un répertoire synchrone impliquent que les modifications seront immédiatement inscrites sur disque. | ||
+ | </ | ||
+ | |||
+ | Les commandes associées avec les attributs sont : | ||
+ | |||
+ | ^ Commande ^ description ^ | ||
+ | | chattr | Modifie les attributs | | ||
+ | | lsattr | Visualise les attributs | | ||
+ | |||
+ | Pour mieux comprendre, créez le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 tmp]# cd /root | ||
+ | [root@centos7 ~]# mkdir -p attributs/ | ||
+ | </ | ||
+ | |||
+ | Créez ensuite les fichier **fichier** et **rep/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# touch attributs/ | ||
+ | [root@centos7 ~]# touch attributs/ | ||
+ | </ | ||
+ | |||
+ | Modifiez les attributs d'une manière récursive sur le répertoire **attributs** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# chattr +i -R attributs/ | ||
+ | </ | ||
+ | |||
+ | Visualisez les attributs de l' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsattr -R attributs | ||
+ | ----i----------- attributs/ | ||
+ | |||
+ | attributs/ | ||
+ | ----i----------- attributs/ | ||
+ | |||
+ | ----i----------- attributs/ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | **Important** - Notez que l' | ||
+ | </ | ||
+ | |||
+ | Essayez maintenant de déplacer le fichier **fichier**. Vous obtiendrez un résultat similaire à celui-ci : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cd attributs; mv / | ||
+ | mv: cannot move ‘/ | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **chattr** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# chattr --help | ||
+ | Usage: chattr [-RVf] [-+=aAcCdDeijsStTu] [-v version] files... | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **lsattr** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsattr --help | ||
+ | lsattr: invalid option -- ' | ||
+ | Usage: lsattr [-RVadlv] [files...] | ||
+ | </ | ||
+ | |||
+ | =====Rôle du noyau===== | ||
+ | |||
+ | Le noyau ou //kernel// est la partie du système d' | ||
+ | |||
+ | * la diminution de la taille du noyau, | ||
+ | * la prise en charge de nouveau matériel, | ||
+ | * l' | ||
+ | * l' | ||
+ | * la correction de bogues, | ||
+ | * le besoin d'une fonctionnalité expérimentale. | ||
+ | |||
+ | Commencez par identifier le noyau utilisé par votre machine : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# uname -r | ||
+ | 3.10.0-327.13.1.el7.x86_64 | ||
+ | </ | ||
+ | |||
+ | Dans le cas d'une utilisation courante de Linux, il est cependant préférable de faire appel aux **modules**. Les modules se trouvent dans le répertoire **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls / | ||
+ | build | ||
+ | extra | ||
+ | kernel | ||
+ | </ | ||
+ | |||
+ | Les commandes pour manipuler les modules sont : | ||
+ | |||
+ | * insmod | ||
+ | * rmmod | ||
+ | * lsmod | ||
+ | * modprobe | ||
+ | |||
+ | Par exemple : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# lsmod | ||
+ | Module | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp, | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | iptable_nat | ||
+ | nf_conntrack_ipv4 | ||
+ | nf_defrag_ipv4 | ||
+ | nf_nat_ipv4 | ||
+ | nf_nat | ||
+ | nf_conntrack | ||
+ | iptable_mangle | ||
+ | iptable_security | ||
+ | iptable_raw | ||
+ | iptable_filter | ||
+ | dm_mirror | ||
+ | dm_region_hash | ||
+ | dm_log | ||
+ | dm_mod | ||
+ | crc32_pclmul | ||
+ | ghash_clmulni_intel | ||
+ | aesni_intel | ||
+ | lrw 13286 1 aesni_intel | ||
+ | gf128mul | ||
+ | glue_helper | ||
+ | snd_intel8x0 | ||
+ | ablk_helper | ||
+ | cryptd | ||
+ | snd_ac97_codec | ||
+ | ac97_bus | ||
+ | ppdev 17671 0 | ||
+ | snd_seq | ||
+ | snd_seq_device | ||
+ | snd_pcm | ||
+ | pcspkr | ||
+ | sg | ||
+ | parport_pc | ||
+ | parport | ||
+ | snd_timer | ||
+ | snd 83425 8 snd_ac97_codec, | ||
+ | soundcore | ||
+ | i2c_piix4 | ||
+ | video 24400 0 | ||
+ | i2c_core | ||
+ | nfsd 302418 | ||
+ | auth_rpcgss | ||
+ | nfs_acl | ||
+ | lockd 93600 1 nfsd | ||
+ | grace 13295 2 nfsd, | ||
+ | sunrpc | ||
+ | ip_tables | ||
+ | xfs | ||
+ | libcrc32c | ||
+ | sd_mod | ||
+ | crc_t10dif | ||
+ | crct10dif_generic | ||
+ | sr_mod | ||
+ | cdrom 42556 1 sr_mod | ||
+ | ata_generic | ||
+ | pata_acpi | ||
+ | ahci | ||
+ | libahci | ||
+ | ata_piix | ||
+ | crct10dif_pclmul | ||
+ | crct10dif_common | ||
+ | crc32c_intel | ||
+ | serio_raw | ||
+ | libata | ||
+ | e1000 | ||
+ | </ | ||
+ | |||
+ | Pour ajouter un module, on peut utiliser la commande **insmod** ou **modprobe**. Cette dernière ajoute non seulement le module passé en argument mais également ses dépendances : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modprobe bonding | ||
+ | [root@centos7 ~]# lsmod | more | ||
+ | Module | ||
+ | bonding | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp, | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | y, | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Pour supprimer un module, on peut utiliser la commande **rmmod** ou **modprobe -r**. Cette dernière essaie de supprimer les dépendances non-utilisées : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modprobe -r bonding | ||
+ | [root@centos7 ~]# lsmod | more | ||
+ | Module | ||
+ | ip6t_rpfilter | ||
+ | ip6t_REJECT | ||
+ | ipt_REJECT | ||
+ | xt_conntrack | ||
+ | ebtable_nat | ||
+ | ebtable_broute | ||
+ | bridge | ||
+ | stp 12976 1 bridge | ||
+ | llc 14552 2 stp, | ||
+ | ebtable_filter | ||
+ | ebtables | ||
+ | ip6table_nat | ||
+ | nf_conntrack_ipv6 | ||
+ | nf_defrag_ipv6 | ||
+ | nf_nat_ipv6 | ||
+ | ip6table_mangle | ||
+ | ip6table_security | ||
+ | ip6table_raw | ||
+ | ip6table_filter | ||
+ | ip6_tables | ||
+ | y, | ||
+ | iptable_nat | ||
+ | --More-- | ||
+ | </ | ||
+ | |||
+ | Les dépendances des modules sont résolues par la commande **modprobe** grâce aux fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# more / | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | to/lrw.ko kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | el/ | ||
+ | kernel/ | ||
+ | helper.ko kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | kernel/ | ||
+ | f128mul.ko kernel/ | ||
+ | kernel/ | ||
+ | --More--(0%) | ||
+ | </ | ||
+ | |||
+ | Il est possible d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# modinfo bonding | ||
+ | filename: | ||
+ | author: | ||
+ | description: | ||
+ | version: | ||
+ | license: | ||
+ | alias: | ||
+ | rhelversion: | ||
+ | srcversion: | ||
+ | depends: | ||
+ | intree: | ||
+ | vermagic: | ||
+ | signer: | ||
+ | sig_key: | ||
+ | sig_hashalgo: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | parm: | ||
+ | </ | ||
+ | |||
+ | Dernièrement, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls / | ||
+ | mlx4.conf | ||
+ | |||
+ | [root@centos7 ~]# cat / | ||
+ | # This file is intended for users to select the various module options | ||
+ | # they need for the mlx4 driver. | ||
+ | # any user made changes to this file are preserved. | ||
+ | # to the libmlx4.conf file in this directory are overwritten on | ||
+ | # pacakge upgrade. | ||
+ | # | ||
+ | # Some sample options and what they would do | ||
+ | # Enable debugging output, device managed flow control, and disable SRIOV | ||
+ | #options mlx4_core debug_level=1 log_num_mgm_entry_size=-1 probe_vf=0 num_vfs=0 | ||
+ | # | ||
+ | # Enable debugging output and create SRIOV devices, but don't attach any of | ||
+ | # the child devices to the host, only the parent device | ||
+ | #options mlx4_core debug_level=1 probe_vf=0 num_vfs=7 | ||
+ | # | ||
+ | # Enable debugging output, SRIOV, and attach one of the SRIOV child devices | ||
+ | # in addition to the parent device to the host | ||
+ | #options mlx4_core debug_level=1 probe_vf=1 num_vfs=7 | ||
+ | # | ||
+ | # Enable per priority flow control for send and receive, setting both priority | ||
+ | # 1 and 2 as no drop priorities | ||
+ | #options mlx4_en pfctx=3 pfcrx=3 | ||
+ | </ | ||
+ | |||
+ | =====Gestion des Quotas===== | ||
+ | |||
+ | Sous Linux il est possible de mettre en place des quotas par utilisateur et par groupe. Ceci étant, Linux ne sait pas gérer des quotas par répertoire, | ||
+ | quotas par partition. L' | ||
+ | |||
+ | Déconnectez-vous et reconnectez-vous en tant que root. | ||
+ | |||
+ | Avant de mettre en place des quotas, configurer SELINUX en mode **permissive** afin de ne pas avoir d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# getenforce | ||
+ | Enforcing | ||
+ | [root@centos7 ~]# setenforce permissive | ||
+ | [root@centos7 ~]# getenforce | ||
+ | Permissive | ||
+ | </ | ||
+ | |||
+ | Editez ensuite le fichier / | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vi / | ||
+ | [root@centos7 ~]# cat / | ||
+ | |||
+ | # This file controls the state of SELinux on the system. | ||
+ | # SELINUX= can take one of these three values: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | SELINUX=permissive | ||
+ | # SELINUXTYPE= can take one of three two values: | ||
+ | # | ||
+ | # | ||
+ | # mls - Multi Level Security protection. | ||
+ | SELINUXTYPE=targeted | ||
+ | </ | ||
+ | |||
+ | ====Déplacer /home==== | ||
+ | |||
+ | Créez une seule partition sur **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# fdisk /dev/sdb | ||
+ | Welcome to fdisk (util-linux 2.23.2). | ||
+ | |||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | Be careful before using the write command. | ||
+ | |||
+ | Device does not contain a recognized partition table | ||
+ | Building a new DOS disklabel with disk identifier 0x88708329. | ||
+ | |||
+ | Command (m for help): n | ||
+ | Partition type: | ||
+ | | ||
+ | | ||
+ | Select (default p): p | ||
+ | Partition number (1-4, default 1): | ||
+ | First sector (2048-41943039, | ||
+ | Using default value 2048 | ||
+ | Last sector, +sectors or +size{K, | ||
+ | Using default value 41943039 | ||
+ | Partition 1 of type Linux and of size 20 GiB is set | ||
+ | |||
+ | Command (m for help): w | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un système de fichiers ext4 sur **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkfs.ext4 /dev/sdb1 | ||
+ | mke2fs 1.42.9 (28-Dec-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=4096 (log=2) | ||
+ | Fragment size=4096 (log=2) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 1310720 inodes, 5242624 blocks | ||
+ | 262131 blocks (5.00%) reserved for the super user | ||
+ | First data block=0 | ||
+ | Maximum filesystem blocks=2153775104 | ||
+ | 160 block groups | ||
+ | 32768 blocks per group, 32768 fragments per group | ||
+ | 8192 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
+ | 4096000 | ||
+ | |||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (32768 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: | ||
+ | </ | ||
+ | |||
+ | Montez **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount /dev/sdb1 /mnt | ||
+ | </ | ||
+ | |||
+ | Copiez le contenu de /home vers /mnt : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cp -a /home/* /mnt | ||
+ | </ | ||
+ | |||
+ | Démontez /dev/sdb1 et déplacez /home vers /root : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# umount /mnt | ||
+ | [root@centos7 ~]# mv /home /root | ||
+ | </ | ||
+ | |||
+ | Identifiez l'UUID de /dev/sdb1 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -l / | ||
+ | lrwxrwxrwx. 1 root root 10 9 août 06:47 a5e2457f-7337-41f4-b958-e403eb419f94 -> ../ | ||
+ | </ | ||
+ | |||
+ | Editez le fichier **/ | ||
+ | |||
+ | <file txt / | ||
+ | # | ||
+ | # / | ||
+ | # Created by anaconda on Sat Apr 30 11:27:02 2016 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info | ||
+ | # | ||
+ | UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / | ||
+ | UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot | ||
+ | UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults | ||
+ | UUID=a5e2457f-7337-41f4-b958-e403eb419f94 / | ||
+ | |||
+ | </ | ||
+ | |||
+ | Créez le point de montage /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mkdir /home | ||
+ | </ | ||
+ | |||
+ | Montez /dev/sdb1 : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# mount -a | ||
+ | [root@centos7 ~]# mount | ||
+ | sysfs on /sys type sysfs (rw, | ||
+ | proc on /proc type proc (rw, | ||
+ | devtmpfs on /dev type devtmpfs (rw, | ||
+ | securityfs on / | ||
+ | tmpfs on /dev/shm type tmpfs (rw, | ||
+ | devpts on /dev/pts type devpts (rw, | ||
+ | tmpfs on /run type tmpfs (rw, | ||
+ | tmpfs on / | ||
+ | cgroup on / | ||
+ | pstore on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | cgroup on / | ||
+ | configfs on / | ||
+ | /dev/sda2 on / type xfs (rw, | ||
+ | selinuxfs on / | ||
+ | systemd-1 on / | ||
+ | debugfs on / | ||
+ | hugetlbfs on / | ||
+ | mqueue on /dev/mqueue type mqueue (rw, | ||
+ | tmpfs on /tmp type tmpfs (rw, | ||
+ | sunrpc on / | ||
+ | nfsd on / | ||
+ | /dev/sda1 on /boot type xfs (rw, | ||
+ | /dev/sdb1 on /home type ext4 (rw, | ||
+ | tmpfs on / | ||
+ | </ | ||
+ | |||
+ | Notez la taille de /home : | ||
+ | |||
+ | < | ||
+ | [trainee@centos7 ~]$ df -h | ||
+ | Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur | ||
+ | / | ||
+ | devtmpfs | ||
+ | tmpfs 245M | ||
+ | tmpfs 245M 4,7M 240M 2% /run | ||
+ | tmpfs 245M | ||
+ | tmpfs 245M | ||
+ | / | ||
+ | / | ||
+ | tmpfs | ||
+ | </ | ||
+ | |||
+ | <WRAP center round todo> | ||
+ | Fermez la session de root et connectez-vous en tant que trainee. | ||
+ | </ | ||
+ | |||
+ | ====Mettre en Place des Quotas==== | ||
+ | |||
+ | Commencez par vérifiez que le paquet **quota** est bien installé : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# rpm -qa | grep quota | ||
+ | quota-4.01-11.el7_2.1.x86_64 | ||
+ | quota-nls-4.01-11.el7_2.1.noarch | ||
+ | </ | ||
+ | |||
+ | Editez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# vi / | ||
+ | [root@centos7 ~]# cat / | ||
+ | |||
+ | # | ||
+ | # / | ||
+ | # Created by anaconda on Sat Apr 30 11:27:02 2016 | ||
+ | # | ||
+ | # Accessible filesystems, | ||
+ | # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info | ||
+ | # | ||
+ | UUID=e65fe7da-cda8-4f5a-a827-1b5cabe94bed / | ||
+ | UUID=2d947276-66e8-41f4-8475-b64b67d7a249 /boot | ||
+ | UUID=3181601a-7295-4ef0-a92c-f21f76b18e64 swap swap defaults | ||
+ | UUID=a080ac6a-d15c-48e2-8461-a7b1aa3ebf1a / | ||
+ | </ | ||
+ | |||
+ | Démontez puis remontez /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# umount /home | ||
+ | [root@centos7 ~]# mount -a | ||
+ | </ | ||
+ | |||
+ | Déconnectez-vous et reconnectez-vous en tant que trainee. Vérifiez ensuite que les options soient prises en compte : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# cat /etc/mtab | ||
+ | rootfs / rootfs rw 0 0 | ||
+ | sysfs /sys sysfs rw, | ||
+ | proc /proc proc rw, | ||
+ | devtmpfs /dev devtmpfs rw, | ||
+ | securityfs / | ||
+ | tmpfs /dev/shm tmpfs rw, | ||
+ | devpts /dev/pts devpts rw, | ||
+ | tmpfs /run tmpfs rw, | ||
+ | tmpfs / | ||
+ | cgroup / | ||
+ | pstore / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | cgroup / | ||
+ | configfs / | ||
+ | /dev/sda2 / xfs rw, | ||
+ | selinuxfs / | ||
+ | systemd-1 / | ||
+ | debugfs / | ||
+ | hugetlbfs / | ||
+ | tmpfs /tmp tmpfs rw,seclabel 0 0 | ||
+ | mqueue /dev/mqueue mqueue rw, | ||
+ | sunrpc / | ||
+ | nfsd / | ||
+ | /dev/sda1 /boot xfs rw, | ||
+ | tmpfs /run/user/0 tmpfs rw, | ||
+ | /dev/sdb1 /home ext4 rw, | ||
+ | </ | ||
+ | |||
+ | ====La Commande quotacheck==== | ||
+ | |||
+ | Pour activer les quotas sur /home, il convient d' | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotacheck -cugvm -f /dev/sdb1 | ||
+ | quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown. | ||
+ | quotacheck: Parcours de /dev/sdb1 [/home] terminé | ||
+ | quotacheck: Cannot stat old user quota file / | ||
+ | quotacheck: Cannot stat old group quota file / | ||
+ | quotacheck: Cannot stat old user quota file / | ||
+ | quotacheck: Cannot stat old group quota file / | ||
+ | quotacheck: Vérifié 100 répertoires et 230 fichiers | ||
+ | quotacheck: Ancien fichier non trouvé. | ||
+ | quotacheck: Ancien fichier non trouvé. | ||
+ | </ | ||
+ | |||
+ | Les options de la commande quotacheck sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotacheck --help | ||
+ | Utility for checking and repairing quota files. | ||
+ | quotacheck [-gucbfinvdmMR] [-F < | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -c, --create-files | ||
+ | -b, --backup | ||
+ | -f, --force | ||
+ | -i, --interactive | ||
+ | -n, --use-first-dquot | ||
+ | -v, --verbose | ||
+ | -d, --debug | ||
+ | -m, --no-remount | ||
+ | -M, --try-remount | ||
+ | continue even if it fails | ||
+ | -R, --exclude-root | ||
+ | -F, --format=formatname | ||
+ | -a, --all check all filesystems | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | Les quotas ont été activés et les fichier **aquota.user** et **aquota.group** ont été créés dans le répertoire /home : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# ls -la /home | ||
+ | total 44 | ||
+ | drwxr-xr-x. | ||
+ | dr-xr-xr-x. 18 root root 4096 11 août 13:27 .. | ||
+ | -rw-------. | ||
+ | -rw-------. | ||
+ | drwx------. | ||
+ | drwx------. 14 trainee trainee | ||
+ | </ | ||
+ | |||
+ | Créez maintenant un utilisateur **fenestros** avec le mot de passe **fenestros** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# groupadd fenestros && useradd fenestros -c FenestrOs -d / | ||
+ | [root@centos7 ~]# passwd fenestros | ||
+ | Changement de mot de passe pour l' | ||
+ | Nouveau mot de passe : fenestros | ||
+ | MOT DE PASSE INCORRECT : Le mot de passe contient le nom d' | ||
+ | Retapez le nouveau mot de passe : fenestros | ||
+ | passwd : mise à jour réussie de tous les jetons d' | ||
+ | [root@centos7 ~]# | ||
+ | </ | ||
+ | |||
+ | ====La Commande edquota==== | ||
+ | |||
+ | Mettez en place maintenant un quota de 10Mo pour l' | ||
+ | |||
+ | < | ||
+ | [root@centos ~]# edquota -u fenestros -f /home | ||
+ | </ | ||
+ | |||
+ | L' | ||
+ | |||
+ | < | ||
+ | Quotas disque pour user fenestros (uid 1001) : | ||
+ | | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Modifiez ce fichier ainsi : | ||
+ | |||
+ | < | ||
+ | Quotas disque pour user fenestros (uid 1001) : | ||
+ | | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **edquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# edquota --help | ||
+ | edquota: Usage: | ||
+ | edquota [-rm] [-u] [-F formatname] [-p username] [-f filesystem] username ... | ||
+ | edquota [-rm] -g [-F formatname] [-p groupname] [-f filesystem] groupname ... | ||
+ | edquota [-u|g] [-F formatname] [-f filesystem] -t | ||
+ | edquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ... | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -r, --remote | ||
+ | -m, --no-mixed-pathnames | ||
+ | -F, --format=formatname | ||
+ | -p, --prototype=name | ||
+ | --always-resolve | ||
+ | composed only of digits | ||
+ | -f, --filesystem=filesystem | ||
+ | -t, --edit-period | ||
+ | -T, --edit-times | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à : jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Pour mettre en place un quota par group, la procédure est similaire. Il suffit d' | ||
+ | </ | ||
+ | |||
+ | ====La Commande quotaon==== | ||
+ | |||
+ | Appliquez maintenant les quotas : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotaon -a | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **quotaon** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quotaon --help | ||
+ | quotaon: Usage: | ||
+ | quotaon [-guvp] [-F quotaformat] [-x state] -a | ||
+ | quotaon [-guvp] [-F quotaformat] [-x state] filesys ... | ||
+ | |||
+ | -a, --all turn quotas on for all filesystems | ||
+ | -f, --off turn quotas off | ||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -p, --print-state | ||
+ | -x, --xfs-command=cmd | ||
+ | -F, --format=formatname | ||
+ | -v, --verbose | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | </ | ||
+ | |||
+ | De cette manière vous avez mis en place un quota **souple** pour fenestros de 8 000 Ko et un quota **stricte** de 10 000 Ko. | ||
+ | |||
+ | Quand l' | ||
+ | |||
+ | Il est à noter que vous pouvez soit mettre en place un quota en taille, soit mettre en place un quota basé sur le nombre d' | ||
+ | |||
+ | <WRAP center round important> | ||
+ | La commande pour désactivez les quotas est **quotaoff**. | ||
+ | </ | ||
+ | |||
+ | ====La Commande repquota==== | ||
+ | |||
+ | Pour visualiser les quotas utilisez la commande **repquota** : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# repquota /home | ||
+ | *** Rapport pour les quotas user sur le périphérique /dev/sdb1 | ||
+ | Période de sursis bloc : 7days ; période de sursis inode : 7days | ||
+ | Block limits | ||
+ | Utilisateur | ||
+ | ---------------------------------------------------------------------- | ||
+ | root -- 20 | ||
+ | trainee | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP center round important> | ||
+ | Notez que l' | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **repquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# repquota --help | ||
+ | repquota: Utility for reporting quotas. | ||
+ | Usage: | ||
+ | repquota [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint) | ||
+ | |||
+ | -v, --verbose | ||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -s, --human-readable | ||
+ | -t, --truncate-names | ||
+ | -p, --raw-grace | ||
+ | -n, --no-names | ||
+ | -i, --no-autofs | ||
+ | -c, --cache | ||
+ | -C, --no-cache | ||
+ | -F, --format=formatname | ||
+ | -a, --all | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | ====La Commande quota==== | ||
+ | |||
+ | Pour visualiser les quotas d'un utilisateur spécifique, | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quota fenestros | ||
+ | Disk quotas for user fenestros (uid 1001): aucun | ||
+ | [root@centos7 ~]# su - fenestros | ||
+ | [fenestros@centos7 ~]$ touch test | ||
+ | [fenestros@centos7 ~]$ exit | ||
+ | logout | ||
+ | [root@centos7 ~]# quota fenestros | ||
+ | Disk quotas for user fenestros (uid 1001): | ||
+ | Système fichiers | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **quota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# quota --help | ||
+ | quota: Usage: quota [-guqvswim] [-l | [-Q | -A]] [-F quotaformat] | ||
+ | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -u username ... | ||
+ | quota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -g groupname ... | ||
+ | quota [-qvswugQm] [-F quotaformat] -f filesystem ... | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -q, --quiet | ||
+ | -v, --verbose | ||
+ | -s, --human-readable | ||
+ | --always-resolve | ||
+ | composed of only digits | ||
+ | -w, --no-wrap | ||
+ | -p, --raw-grace | ||
+ | -l, --local-only | ||
+ | -Q, --quiet-refuse | ||
+ | not respond | ||
+ | -i, --no-autofs | ||
+ | -F, --format=formatname | ||
+ | -f, --filesystem-list | ||
+ | -A, --all-nfs | ||
+ | -m, --no-mixed-pathnames | ||
+ | --show-mntpoint | ||
+ | --hide-device | ||
+ | -h, --help | ||
+ | -V, --version | ||
+ | |||
+ | Rapports de bugs à : jack@suse.cz | ||
+ | </ | ||
+ | |||
+ | ====La Commande warnquota==== | ||
+ | |||
+ | La commande **warnquota** vérifie le ou les disques et envoie un message par mail à tout utilisateur qui a dépassé la limite soft. Elle est enrègle générale appelée par un job cron. Cependant elle peut aussi est appelée d'une manière intéractive. | ||
+ | |||
+ | Sous RHEL/CentOS 7, warnquota n'est pas installé par défaut : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# yum install quota-warnquota | ||
+ | Modules complémentaires chargés : fastestmirror, | ||
+ | base | 3.6 kB 00: | ||
+ | extras | ||
+ | updates | ||
+ | Loading mirror speeds from cached hostfile | ||
+ | * base: centos.quelquesmots.fr | ||
+ | * extras: miroir.univ-paris13.fr | ||
+ | * updates: miroir.univ-paris13.fr | ||
+ | Résolution des dépendances | ||
+ | --> Lancement de la transaction de test | ||
+ | ---> Le paquet quota-warnquota.x86_64 1: | ||
+ | --> Résolution des dépendances terminée | ||
+ | |||
+ | Dépendances résolues | ||
+ | |||
+ | ======================================================================================================================================================================== | ||
+ | | ||
+ | ======================================================================================================================================================================== | ||
+ | Installation : | ||
+ | | ||
+ | |||
+ | Résumé de la transaction | ||
+ | ======================================================================================================================================================================== | ||
+ | Installation | ||
+ | |||
+ | Taille totale des téléchargements : 76 k | ||
+ | Taille d' | ||
+ | Is this ok [y/d/N]: y | ||
+ | </ | ||
+ | |||
+ | Les options de la commande **warnquota** sont : | ||
+ | |||
+ | < | ||
+ | [root@centos7 ~]# warnquota --help | ||
+ | warnquota: Usage: | ||
+ | warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile] [-a adminsfile] [filesystem...] | ||
+ | |||
+ | -u, --user | ||
+ | -g, --group | ||
+ | -s, --human-readable | ||
+ | -i, --no-autofs | ||
+ | -d, --no-details | ||
+ | -F, --format=formatname | ||
+ | -c, --config=config-file | ||
+ | -q, --quota-tab=quotatab-file | ||
+ | -a, --admins-file=admins-file | ||
+ | -h, --help | ||
+ | -v, --version | ||
+ | |||
+ | Rapports de bugs à jack@suse.cz | ||
+ | </ | ||
----- | ----- | ||
- | Copyright © 2023 Hugh Norris. | + | Copyright © 2024 Hugh Norris. |