Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| elearning:workbooks:redhat:rh124:l107 [2024/09/27 10:57] – admin | elearning:workbooks:redhat:rh124:l107 [2024/11/27 10:14] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 26: | Ligne 26: | ||
| * 2.2 - Inheritance Flag | * 2.2 - Inheritance Flag | ||
| * 2.3 - Sticky bit | * 2.3 - Sticky bit | ||
| + | * LAB #3 - Les Droits Unix Avancés | ||
| + | * 3.1 - Les ACL | ||
| + | * 3.2 - Les Attributs Étendus | ||
| =====Présentation===== | =====Présentation===== | ||
| Ligne 516: | Ligne 518: | ||
| </ | </ | ||
| + | =====LAB #3 - Les Droits Unix Avancés===== | ||
| + | |||
| + | ====3.1 - Les ACL==== | ||
| + | |||
| + | Au delà des droits étendus d' | ||
| + | |||
| + | Pour connaître les ACL positionnés sur un fichier, il convient d' | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# getfacl / | ||
| + | getfacl: Removing leading '/' | ||
| + | # file: home/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user::rw- | ||
| + | group::r-- | ||
| + | other::r-- | ||
| + | </ | ||
| + | |||
| + | Pour positionner des ACL sur un fichier, il convient d' | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# setfacl --set u:: | ||
| + | [root@redhat9 tmp]# getfacl / | ||
| + | getfacl: Removing leading '/' | ||
| + | # file: home/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user::rwx | ||
| + | user: | ||
| + | group::r-x | ||
| + | mask::rwx | ||
| + | other::--- | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 60%> | ||
| + | **Important** - Veuillez noter l' | ||
| + | </ | ||
| + | |||
| + | Regardez maintenant l' | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# mkdir / | ||
| + | </ | ||
| + | |||
| + | Positionnez des ACL le répertoire avec la commande **setfacl** : | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# setfacl --set d: | ||
| + | </ | ||
| + | |||
| + | Notez l' | ||
| + | |||
| + | Créez maintenant un fichier appelé fichier1 dans / | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# touch / | ||
| + | </ | ||
| + | |||
| + | Utilisez la commande **getfacl** pour visualiser le résultat : | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# getfacl / | ||
| + | getfacl: Removing leading '/' | ||
| + | # file: home/ | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user::rwx | ||
| + | group::r-x | ||
| + | other::r-x | ||
| + | default: | ||
| + | default: | ||
| + | default: | ||
| + | |||
| + | [root@redhat9 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, | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# cd / | ||
| + | [root@redhat9 rep1]# getfacl -R --skip-base . > backup.acl | ||
| + | [root@redhat9 rep1]# cat backup.acl | ||
| + | # file: . | ||
| + | # owner: root | ||
| + | # group: root | ||
| + | user::rwx | ||
| + | group::r-x | ||
| + | other::r-x | ||
| + | default: | ||
| + | default: | ||
| + | default: | ||
| + | </ | ||
| + | |||
| + | La restauration des ACL se fait avec la commande **setfacl** : | ||
| + | |||
| + | # setfacl --restore=backup.acl [Entrée] | ||
| + | |||
| + | ==Options des Commandes=== | ||
| + | |||
| + | Les options de la commande **getfacl** sont : | ||
| + | |||
| + | < | ||
| + | [root@redhat9 tmp]# getfacl --help | ||
| + | getfacl 2.2.53 -- 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@redhat9 tmp]# setfacl --help | ||
| + | setfacl 2.2.53 -- 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 | ||
| + | </ | ||
| + | |||
| + | ====3.2 - 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 60%> | ||
| + | **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@redhat9 rep1]# cd /root | ||
| + | [root@redhat9 ~]# mkdir -p attributs/ | ||
| + | </ | ||
| + | |||
| + | Créez ensuite les fichier **fichier** et **rep/ | ||
| + | |||
| + | < | ||
| + | [root@redhat9 ~]# touch attributs/ | ||
| + | [root@redhat9 ~]# touch attributs/ | ||
| + | </ | ||
| + | |||
| + | Modifiez les attributs d'une manière récursive sur le répertoire **attributs** : | ||
| + | |||
| + | < | ||
| + | [root@redhat9 ~]# chattr +i -R attributs/ | ||
| + | </ | ||
| + | |||
| + | Visualisez les attributs de l' | ||
| + | |||
| + | < | ||
| + | [root@redhat9 ~]# lsattr -R attributs | ||
| + | ----i----------- attributs/ | ||
| + | |||
| + | attributs/ | ||
| + | ----i----------- attributs/ | ||
| + | |||
| + | ----i----------- attributs/ | ||
| + | </ | ||
| + | |||
| + | Essayez maintenant de déplacer le fichier **fichier**. Vous obtiendrez un résultat similaire à celui-ci : | ||
| + | |||
| + | < | ||
| + | [root@redhat9 ~]# cd attributs; mv / | ||
| + | mv: cannot move '/ | ||
| + | </ | ||
| ----- | ----- | ||
| Copyright © 2024 Hugh Norris. | Copyright © 2024 Hugh Norris. | ||