Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

setfacl

Add, change or remove ACL entries: rights for extra users and groups on files and directories.

Niveau
Dagelijks Linux
Groep
Rechten
Root nodig
Voor wijzigingen
Pakket
acl

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

Normal permissions have one owner and one group. With setfacl you add more: u:carol:rx for a user, g:account:rwx for a group. A default ACL (-d) on a directory is copied to new files and directories in it.

The mask is the maximum for all named users and groups and the owning group. setfacl sets it automatically; chmod g=... on a file with an ACL changes the mask.

Only the owner or root may change an ACL. XFS and ext4 on RHEL support ACLs without extra mount options.

Zo schrijf je het

setfacl [-bkndRLPvh] [{-m|-x} ACL] [{-M|-X} FILE] FILE...
setfacl --set=ACL FILE...
setfacl --restore=FILE

Belangrijkste delen

u:USER:PERMS
Rights for a named user (u::PERMS = the owner).
g:GROUP:PERMS
Rights for a named group (g::PERMS = the owning group).
m::PERMS
The mask.
o::PERMS
Others.
d:ENTRY
A default entry (same as -d).
PERMS
r, w, x, X (x only for folders) or - ; numbers 0–7 work too.

Opties 18

Meest gebruikt

-m, --modify=ACL
Add or change entries.
-M, --modify-file=FILE
Read the entries to change from a file (- = stdin).
-x, --remove=ACL
Remove entries (without the rights part, like u:carol).
-X, --remove-file=FILE
Read the entries to remove from a file.
-b, --remove-all
Remove all extra entries (normal mode stays).
-k, --remove-default
Remove the default ACL.
-d, --default
Work on the default ACL.
-R, --recursive
Work on the whole tree.
--set=ACL
Replace the whole ACL.
--set-file=FILE
Replace the whole ACL from a file.
-n, --no-mask
Do not recalculate the mask.
--mask
Recalculate the mask.
--restore=FILE
Restore ACLs from a getfacl -R dump.
--test
Show the result but change nothing.
-L, --logical
Follow links to directories.
-P, --physical
Do not follow links.
-v, --version
Show the version.
-h, --help
Show help.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Give one user read access

    setfacl -m u:carol:r report.txt

    carol may read; the normal mode stays.

  2. 2Give a group full access to a folder

    setfacl -m g:account:rwx /srv/sales

    A second team without changing the owning group.

  3. 3Make new files inherit the rights

    setfacl -d -m g:account:rwX /srv/sales

    Without -d only existing entries change.

  4. 4Existing files and new files together

    setfacl -R -m g:account:rX /srv/sales
    setfacl -d -m g:account:rX /srv/sales

    First the tree, then the default for later files.

  5. 5Remove one entry

    setfacl -x u:carol report.txt

    Only carol's entry goes.

  6. 6Remove all ACLs

    setfacl -R -b /srv/sales

    Back to the normal permissions.

  7. 7Let a service read a log folder

    setfacl -R -m u:promtail:rX /var/log/httpd
    setfacl -d -m u:promtail:rX /var/log/httpd

    A log shipper reads logs without being root or in the group (least privilege).

  8. 8Let a user only pass through a folder

    setfacl -m u:carol:x /home/lisa

    carol can reach a file inside (if she may read it) but cannot list the folder.

  9. 9Test before you change

    setfacl --test -m u:carol:rw report.txt

    Shows the new ACL only.

  10. 10Restore a backup of ACLs

    setfacl --restore=/root/srv-acl.txt

    The dump from getfacl -R.

  11. 11Fix rights cut by the mask

    setfacl -m m::rwx /srv/sales/plan.txt

    The mask limits named entries; set it back to rwx.

Let op

  • The mask limits named users and groups. Check #effective: in getfacl.
  • A default ACL on a folder replaces the umask for new files there.
  • Backups need ACL support: tar --acls, rsync -A.

Exitcodes

0Done.
1Error.