Linux Intermediate 02 — Access Control Lists and Shared Directories

Linux course index · Linux Intermediate category · Lesson 2 of 9

AI disclosure — AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.

Learning goal

Grant and remove a narrowly scoped named-user ACL and distinguish a grant from effective access.

Concepts and setup

In an extended POSIX ACL, the mask caps permissions for the owning group and named nonowner entries. Access ACLs affect the object itself. Default ACLs exist on directories and can affect newly created children. They do not rewrite children that already exist. A named-user grant on a file is not enough if the user cannot traverse its parents.

Use a VM with getfacl and setfacl installed. This demonstrates policy on a fixture, not access through the private mktemp parent. The command uses the numeric ID of the local nobody account only for a lab fixture.

Grant, limit, and remove a named-user entry

getent passwd nobody
lab=$(mktemp -d)
cd "$lab" || exit
printf 'training report\n' > report.txt
chmod 600 report.txt
guest=$(id -u nobody)
setfacl -m "u:$guest:rw-" report.txt
setfacl -m m::r-- report.txt
getfacl -n report.txt
setfacl -x "u:$guest" report.txt
getfacl -n report.txt

Possible output

# file: report.txt
# owner: 1000
# group: 1000
user::rw-
user:65534:rw-           #effective:r--
group::---
mask::r--
other::---
...
user::rw-
group::---
mask::---
other::---

Output omits the getent line and includes an illustrative numeric ID. After removing the named entry, the mask can still be present. Inspect the remaining entries rather than inferring that every access path is gone.

Compare a default ACL with the child’s access ACL

mkdir shared
setfacl -m "d:u:$guest:r-x" shared
touch shared/new.txt
getfacl -cn shared | grep '^default:user:'
getfacl -cn shared/new.txt | grep -E '^(user:[0-9]+:|mask::)'

Possible output

default:user::rwx
default:user:65534:r-x
user:65534:r-x           #effective:r--
mask::rw-

The new regular file’s creation mode can limit inherited permissions. Removing the default entry on shared will not remove an ACL on new.txt.

Questions only

Quick-check questions

  1. What does the mask mean for a named rw- grant?
  2. What is the difference between an access ACL and a default ACL?

Assessment questions

  1. Remove the named default ACL from shared without changing other entries.
  2. Why might the user still be unable to read the file after an ACL shows r–?
  3. Can removal of a named entry guarantee the user has no access? Explain.

Questions and answers

Quick-check answers

  1. What does the mask mean for a named rw- grant?
    Answer — Only the permitted intersection is effective. A mask of r– removes effective write.
  2. What is the difference between an access ACL and a default ACL?
    Answer — An access ACL is checked on its object. A default ACL can be inherited by new children.

Assessment answer key

  1. Remove the named default ACL from shared without changing other entries.
    Answer — setfacl -x "d:u:$guest" shared. Check the child separately.
  2. Why might the user still be unable to read the file after an ACL shows r–?
    Answer — A parent may lack traverse permission, or another policy such as SELinux may deny access.
  3. Can removal of a named entry guarantee the user has no access? Explain.
    Answer — No. Ownership, an owning-group rule, another group rule, or the others entry can independently matter. Check effective access as the intended user.

Source articles on this site

Continue the course

Previous lesson 01 — Users, Groups, sudo, and Special Permissions. Next lesson 03 — Bash Variables, Quoting, and Input.

Linux course index · Linux Intermediate category · Lesson 2 of 9

Leave a Reply