brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: setfacl gives one extra user access without changing the group

Acl
~/tips/tip-linux-setfacl

sudo setfacl -m u:alice:rX /srv/data

Gives one extra named user access to a folder without touching owner or group.

Classic permissions have one owner, one group and everyone else. When a fourth person needs access to a folder, people usually widen the group or use chmod 777. Please do neither.

An ACL lets you add one named user:

sudo setfacl -m u:alice:rX /srv/data
getfacl /srv/data

-m modifies the ACL, and u:alice:rX gives alice read access, with execute on directories. getfacl prints the full list. Add -R for existing contents and -d to set a default ACL, so files created later inherit it.

You can spot ACLs in ls -l: a plus sign after the permission letters. The caveat is that the filesystem must support ACLs (ext4, XFS and btrfs do by default) and the tools come from the acl package, which not every minimal install has. Also remember the ACL mask: it can cap what the named user really gets, and getfacl shows it as the effective rights.

Many people skip ACLs because they sound like enterprise stuff. In practice it is one command, and the normal permissions stay readable. To remove an entry again, use setfacl -x u:alice /srv/data, and setfacl -b strips all of them. Undoing it is easy, so it is safe to try.

Further reading: setfacl man page, acl man page, On this site: use a capital X in chmod so only directories get execute, On this site: stat -c prints the permissions as numbers

More Acl tips setfacl -m m::rx file All Acl tips (2) All topics

Link