A batch service generates reports, an audit process needs read-only access, and other local accounts must have no access. On the same dedicated server, shared directories like this are often temporarily made writable by everyone, only for a deployment script to tighten permissions again with chmod. The result is intermittent failures. POSIX ACLs let you grant access separately, but validation must cover the actual identities, inheritance for new files, and denied operations—not just a permissions string.
1. Set up an isolated permissions lab
This example uses Debian 12. The lab works only in a temporary directory and does not modify production paths. This free operating system is available for TermAMD dedicated servers; after payment, view the credentials in the control panel and connect over SSH. Run all the commands below in the same root shell with administrative privileges so that the directory variable remains available.
Install the tools first, then create three lab accounts that cannot log in interactively. If any account or group with the same name already exists, stop and choose a different set of names. Do not reuse existing production identities.
apt-get update
apt-get install -y acl
for name in taclwrite taclread taclother; do
if getent passwd "$name" >/dev/null || getent group "$name" >/dev/null; then
printf 'Account or group already exists: %s\n' "$name"
exit 1
fi
done
for name in taclwrite taclread taclother; do
useradd --system --user-group --no-create-home \
--shell /usr/sbin/nologin "$name"
done
LAB=$(mktemp -d /var/tmp/termamd-acl.XXXXXX)
printf '%s\n' "$LAB"
findmnt -T "$LAB"
taclwrite represents the producer, taclread the reader, and taclother an account with no authorized access. The file system must support POSIX ACLs. If a later setfacl command returns “Operation not supported,” check the file system and mount capabilities first rather than loosening permissions for everyone.
The lab directory is owned by root, while ordinary accounts receive access through named ACL entries. This also separates directory ownership from service identities, preventing owner permissions from hiding the mask's effect.
2. Separate access permissions from default inheritance
An access ACL determines who can currently traverse, list, and write to a directory. A default ACL helps determine the permissions of newly created child objects. Configure them separately.
setfacl -m \
u::rwx,u:taclwrite:rwx,u:taclread:r-x,g::---,m::rwx,o::--- \
"$LAB"
setfacl -d -m \
u::rwx,u:taclwrite:rwx,u:taclread:r-x,g::---,m::rwx,o::--- \
"$LAB"
getfacl -p "$LAB"
namei -l "$LAB"
On a directory, r allows listing names, x allows path traversal, and w must be combined with x to create or delete directory entries. A read-only account therefore needs r-x, not simply r--. Even if the target directory's ACL is correct, missing search permission on a parent path will block access.
A default ACL is not a background synchronization mechanism: it does not retroactively change existing files or guarantee that files moved in from elsewhere automatically receive the same permissions.
New regular files are usually created with a requested mode of 0666, so execute bits in default entries do not turn them into executable files. When a default ACL exists, you cannot simply apply the rule “final permissions equal the creation mode minus umask.” You must also examine the inherited permissions and the mode requested by the program.
3. Test allowed and denied operations under the actual identities
First, have the producer create a report with a restrictive umask, then have the reader open it. The commands pass the path as an argument so that the directory variable is not lost in a nested shell.
runuser -u taclwrite -- sh -c \
'umask 077; printf "batch=ok\n" > "$1/report.txt"' sh "$LAB"
getfacl -p "$LAB/report.txt"
runuser -u taclread -- cat "$LAB/report.txt"
if runuser -u taclread -- sh -c \
'printf "unexpected\n" >> "$1/report.txt"' sh "$LAB"; then
printf 'FAIL: reader wrote data\n'
else
printf 'PASS: reader write denied\n'
fi
if runuser -u taclother -- cat "$LAB/report.txt"; then
printf 'FAIL: unrelated account read data\n'
else
printf 'PASS: unrelated account denied\n'
fi
The expected result is a successful write by the producer, batch=ok output from the reader, and explicit denials for the other two operations. Save failure messages alongside exit statuses. In a negative test, “Permission denied” is evidence that the check passed, not a fault to eliminate.
Also test that the reader cannot create or delete files. Preventing changes to file contents and preventing deletion of directory entries are separate boundaries: even if a file itself is read-only, an account with write and search permissions on the parent directory may still be able to delete or replace it.
These three identities do not model the entire production environment. In production, also verify the user the service actually runs as, its supplementary groups, and UID mappings inside and outside containers. Running cat only in a root session does not prove that the service has the intended permissions.
4. Reproduce mask and file-move pitfalls
Which permission layer does chmod change?
When an extended ACL exists, the group permission bits shown by ls -l usually correspond to the mask, not just the owning-group entry. The mask limits the effective permissions of named users, the owning group, and named groups. It does not limit the file owner's permissions or the other entry.
The following commands modify only the lab directory. After permissions are tightened, the producer's named rwx entry may still appear in the output, but its effective permissions no longer include writing.
chmod g-w "$LAB"
getfacl -p "$LAB"
if runuser -u taclwrite -- touch "$LAB/blocked"; then
printf 'FAIL: mask did not block creation\n'
else
printf 'PASS: creation denied by mask\n'
fi
setfacl -m m::rwx "$LAB"
runuser -u taclwrite -- touch "$LAB/allowed"
rm -- "$LAB/allowed"
Focus on the effective annotation and the results of actual operations. Before restoring the mask, review every entry it limits. Expanding the mask may also enable permissions already declared for other named accounts but previously blocked by the mask.
Moving a file in does not recreate it
A rename within the same file system usually preserves the original inode and ACL. It does not inherit the destination directory's default ACL again. A move across file systems involves copying and deletion, and the outcome also depends on how the tool preserves attributes. Do not treat a move as a way to repair permissions.
If a deployment workflow generates files elsewhere and then moves them into the shared directory, check the ACLs on the final files. A program that explicitly creates files with mode 0600, a later chmod, or an atomic replacement of an old file with a temporary file can also remove the reader's access. Validate the new file at the final path, not the old inode before replacement.
5. Turn the lab results into production checks
Before changing a production directory, record its owner, group, access ACL, and default ACL. You can export the target tree with getfacl -R -p; store the output outside that tree and restrict read access to it. To restore permissions, use a verified backup with setfacl --restore. Restoring ACLs does not recover deleted content, and permission records are not a substitute for data backups.
Retain at least the following validation results when deploying:
- Check new files and new subdirectories separately to confirm that inheritance applies as intended.
- Verify that the producer can perform real writes and replacements, while the reader can read but cannot create, delete, or modify files.
- Confirm that an unauthorized account cannot list the directory or open a file whose name it knows.
- Run the same checks again after the deployment script performs chmod, copying, or atomic replacement.
- Verify the process identity after restarting the service, so that an old process's group list does not hide configuration changes.
Default ACLs provide inheritance rules only. They do not replace application-level authorization, read-only mounts, or other security policies. If an operation is still denied, check the path, effective ACL, and runtime environment layer by layer instead of recursively making everything writable by everyone.
When the lab is finished, remove only the objects created for it. If additional files are present, rmdir will refuse to remove the directory. Investigate where those files came from rather than hiding leftovers with forced recursive deletion.
rm -- "$LAB/report.txt"
rmdir -- "$LAB"
for name in taclwrite taclread taclother; do
userdel "$name"
done
A shared directory passes validation not when its permissions “look right,” but when the designated identities can perform the intended actions, prohibited actions consistently fail, and the same results remain reproducible after deployment.
Frequently asked questions
Will a default ACL fix permissions on existing files?
No. A default ACL participates in permission creation for new objects only. Existing files require a separate audit and explicit access ACL changes.
Why is writing denied when the ACL entry says rwx?
Named-user permissions are limited by the ACL mask. Parent directories must also allow traversal. Check effective permissions in getfacl, the full path and mount restrictions.