Ravindra BagaleCourses & study guides मराठी Track your progress

AWS Cloud

Linux ACL and File Attributes: setfacl, getfacl, chattr and lsattr with Examples

Normal permissions give rights to one owner, one group and everyone else. Sometimes you need more: give one extra user read access, or give two teams different rights on the same folder. ACLs (Access Control Lists) do that. File attributes (chattr) add another layer: a file can be made immutable so even root cannot change it, or append-only for logs.

In this chapter

  • Know when ACLs are needed
  • Read ACLs with getfacl and spot the + in ls -l
  • Add, change and remove ACLs with setfacl
  • Use default ACLs and understand the mask
  • Keep ACLs during copy, backup and restore
  • Use lsattr and chattr +i / +a

1. An everyday example: a housing society notice room

In a Kothrud society, the office room belongs to the secretary and the committee. The plumber also needs to enter on Tuesdays, but he is not on the committee. Instead of adding him to the committee, the secretary writes his name on a special list at the door: 'Plumber: may enter, may not touch files'. The society rule book is laminated and locked in glass: nobody can change it, not even the secretary, until the glass is unlocked. The visitor register only allows new lines; old lines cannot be erased.

Owner and group = secretary and committee. Special list at the door = ACL. 'May enter, may not touch' = r-x for one user. Locked glass = chattr +i (immutable). Visitor register = chattr +a (append-only).

How Linux checks a file with an ACLIs the process the owner? Use owner bitsIs there a named user entry for it? Use it, limited by maskDoes a group or named group match? Use the best one, limited by maskElse use other bitsThen attributes: +i blocks all changes, +a allows only appendingFinally SELinux/AppArmor may still say no
The mask is the ceiling for named users and all groups.

2. Why ACLs: limits of owner/group/other

A file has only one group. If finance needs read and audit needs read-write on the same folder, normal bits cannot do it without messy groups.

ACLs add extra entries: user:NAME:rwx and group:NAME:rwx, plus a mask and defaults for new files. They work on ext4, XFS and most modern file systems (mounted with acl, which is the default). A + at the end of ls -l mode means an ACL exists.

  1. Spot an ACL.
ls -ld /srv/reports

Output:

drwxrwx---+ 2 ravi finance 4096 Oct 25 /srv/reports

The + means there is more than the 9 bits.

  1. Is the tool installed?
command -v setfacl getfacl || sudo dnf install -y acl

Output:

/usr/bin/setfacl
/usr/bin/getfacl

Package name is acl.

3. getfacl: read an ACL

Suppose ls -l shows a plus sign after the permission bits. Read getfacl to see the additional entries. The line user::rw- is for the file owner. A line such as user:asha:r-- names a different person. The mask limits the named users, the owning group and named groups, so compare any #effective: result before deciding what that person can do. Trace the parent directories too. Someone can have read access on the file and still be unable to reach it through a folder they cannot enter.

Before changing or debugging access you must see every entry, including the mask.

getfacl FILE prints owner, group, then user::, user:NAME:, group::, group:NAME:, mask::, other::, and default: lines for folders. '#effective:' shows rights cut by the mask. -R walks a tree. -c hides the header.

  1. Read a folder ACL.
getfacl /srv/reports

Output:

# file: srv/reports
# owner: ravi
# group: finance
user::rwx
user:priya:r-x
group::rwx
group:audit:rwx
mask::rwx
other::---

priya can read, audit can write.

  1. Without header.
getfacl -c /srv/reports/q3.csv

Output:

user::rw-
user:priya:r--
group::r--
mask::r--
other::---

Short and easy to compare.

  1. An effective right cut by the mask.
getfacl -c data.csv | grep effective

Output:

user:sam:rw-		#effective:r--

sam's w is blocked by the mask.

4. setfacl -m: add or change an entry

Give one more person or team access without changing the owner, group or other bits.

setfacl -m u:NAME:rwx FILE for a user, -m g:NAME:rx for a group, -m o::- for others. Several at once with commas. -R for a tree (use X to give x only on folders). The mask updates automatically.

  1. Let priya read one file.
setfacl -m u:priya:r q3.csv && getfacl -c q3.csv | grep priya

Output:

user:priya:r--

No group change needed.

  1. Give the audit team write.
setfacl -m g:audit:rw q3.csv && ls -l q3.csv

Output:

-rw-rw----+ 1 ravi finance 9K Oct 25 q3.csv

The group bits shown are now the mask.

  1. Whole tree, folders get x.
setfacl -R -m g:audit:rX /srv/reports

Output:

(no output)

Files are r, folders r-x.

  1. Let nginx pass through a home folder.
setfacl -m u:nginx:x /home/ravi

Output:

(no output)

Only x: it can reach public_html but cannot list home.

5. Default ACLs: rules for new files

Think about reports already in the folder and reports created tomorrow. An access ACL covers a specific file or directory now. A default ACL lives on a directory as a pattern for newly created entries. You can put one practice file in the folder before setting the default and create a second after it. Compare their ACLs to see why the audit team might be able to read the second one before you grant access on the first. If a new file is moved in from elsewhere on the same filesystem, check that file separately because the rename can keep its old access ACL.

Without defaults, new files in a shared folder get no ACL and the extra team loses access.

A default ACL on a folder (setfacl -d -m or -m d:...) is copied to new files and sub-folders created inside. It does not change existing files, so pair it with -R -m for those. Only folders can have defaults.

Look at the getfacl output for q4.csv below. The named entry still shows r-x from the parent, but the new file was created without execute permission. The access ACL mask leaves the audit group with r--. Check #effective: on the new file when you want to know what a person can actually do.

  1. Set a default for audit.
setfacl -d -m g:audit:rX /srv/reports && getfacl -c /srv/reports | grep default

Output:

default:user::rwx
default:group::rwx
default:group:audit:r-x
default:mask::rwx
default:other::---

Future files get audit access.

  1. Check a new file.
touch /srv/reports/q4.csv && getfacl -c /srv/reports/q4.csv | grep audit

Output:

group:audit:r-x		#effective:r--

Inherited; files do not get x.

  1. Existing plus future in two steps.
setfacl -R -m g:audit:rX /srv/reports && setfacl -R -d -m g:audit:rX /srv/reports

Output:

(no output)

Common pattern for shared folders.

6. The ACL mask

People add rw for a user and it still fails. Usually the mask is lower, often after a chmod.

mask:: is the maximum right for named users, named groups and the owning group. When a file has an ACL, chmod g=... changes the mask, not the group. setfacl -m m::rwx sets it. setfacl -n stops automatic mask recalculation.

  1. chmod shrinks the mask.
chmod 640 q3.csv && getfacl -c q3.csv | grep -E 'audit|mask'

Output:

group:audit:rw-		#effective:r--
mask::r--

audit lost write.

  1. Restore the mask.
setfacl -m m::rw q3.csv && getfacl -c q3.csv | grep mask

Output:

mask::rw-

audit can write again.

7. setfacl -x and -b: remove entries

When a contractor leaves or a test is over, remove the extra access cleanly.

setfacl -x u:NAME FILE removes one user entry, -x g:NAME a group entry. -k removes all default entries. -b removes the whole ACL and leaves only normal bits. -R for trees.

  1. Remove priya.
setfacl -x u:priya q3.csv && getfacl -c q3.csv | grep -c priya

Output:

0

Her extra access is gone.

  1. Remove defaults only.
setfacl -k /srv/reports

Output:

(no output)

Existing entries stay.

  1. Remove all ACLs from a tree.
setfacl -R -b /srv/old && ls -ld /srv/old

Output:

drwxrwx--- 2 ravi finance 4096 /srv/old

The + is gone.

8. Copy, back up and restore ACLs

A plain cp or tar can silently drop ACLs, and after a restore people lose access.

cp -a (or --preserve=all) keeps ACLs. rsync -aAX keeps ACLs and xattrs. tar --acls --xattrs on create and extract. getfacl -R > file saves them; setfacl --restore=file puts them back. Copy one file's ACL to another: getfacl a | setfacl --set-file=- b.

  1. Save ACLs of a tree.
getfacl -R /srv/reports > /root/reports.acl && wc -l /root/reports.acl

Output:

58 /root/reports.acl

A text backup of rights.

  1. Restore them.
cd / && setfacl --restore=/root/reports.acl

Output:

(no output)

Paths are relative to /.

  1. rsync with ACLs.
rsync -aAX /srv/reports/ backup:/srv/reports/

Output:

(no output)

A = ACLs, X = xattrs.

  1. tar with ACLs.
tar --acls --xattrs -czf reports.tgz /srv/reports

Output:

(no output)

Use --acls again when extracting.

9. lsattr: list file attributes

A file that even root cannot delete is usually immutable. lsattr shows it.

lsattr FILE shows attribute letters: i immutable, a append-only, e extents (normal on ext4), A no atime update, d no dump. lsattr -d FOLDER for the folder itself, -R recursive. Works best on ext4; XFS supports i and a.

  1. Normal file.
lsattr notes.txt

Output:

--------------e------- notes.txt

Only e: normal ext4 file.

  1. Immutable file.
lsattr /etc/resolv.conf

Output:

----i---------e------- /etc/resolv.conf

Someone locked it.

  1. Find all immutable files in /etc.
sudo lsattr -R /etc 2>/dev/null | grep -- '-i-'

Output:

----i---------e------- /etc/resolv.conf

Useful after 'cannot modify' errors.

10. chattr +i: make a file immutable

Ordinary permission bits and ACLs answer who is allowed to act. Filesystem attributes add another condition to some operations. In the lab, first show that you can append one line to your own sample file. After setting the immutable attribute, try the same append and read the error. Check the attribute with lsattr before you investigate another permission rule. Then clear the attribute using the lab account with the required privilege and confirm the append works again. That sequence isolates one change and shows which layer blocked the write.

Stop accidental or automatic changes to a critical file (for example DNS config overwritten by a tool).

sudo chattr +i FILE: nobody, including root, can write, delete, rename or link it until chattr -i. Only root (CAP_LINUX_IMMUTABLE) can set or clear it. On a folder, no files can be added or removed inside.

  1. Lock the file.
sudo chattr +i /etc/resolv.conf && lsattr /etc/resolv.conf

Output:

----i---------e------- /etc/resolv.conf

Locked.

  1. Even root is refused.
sudo rm /etc/resolv.conf

Output:

rm: cannot remove '/etc/resolv.conf': Operation not permitted

Permissions are fine; the attribute blocks it.

  1. Unlock to edit.
sudo chattr -i /etc/resolv.conf && sudo vi /etc/resolv.conf

Output:

(editor opens)

Lock again after editing.

11. chattr +a: append-only

Logs should grow but never be edited or truncated, even by an attacker who got a service account.

sudo chattr +a FILE: data can only be added at the end (>>). Overwrite (>), truncate and delete fail. Log rotation must clear it first (chattr -a) or use a postrotate step.

  1. Make a log append-only.
sudo chattr +a /var/log/audit-trail.log && lsattr /var/log/audit-trail.log

Output:

-----a--------e------- /var/log/audit-trail.log

A is set.

  1. Appending works.
echo 'login ravi' | sudo tee -a /var/log/audit-trail.log

Output:

login ravi

New line added.

  1. Overwriting fails.
echo x | sudo tee /var/log/audit-trail.log

Output:

tee: /var/log/audit-trail.log: Operation not permitted

History is safe.

12. Real examples from many industries

The same Linux skill shows up in every kind of company. Seeing it in many places helps you remember it.

Each row is a made-up team. It shows who uses this and how.

Team and cityHow they use itCommand
Pooja, CA firm, PuneGives one auditor read access to a client foldersetfacl -R -m u:auditor:rX /srv/clients/acme
Lars, media house, StockholmDefault ACL so editors keep access to new videossetfacl -d -m g:editors:rwX /srv/media
Fatima, hospital, DubaiAppend-only access logchattr +a /var/log/emr-access.log
Diego, ISP, Mexico CityLocks resolv.conf against DHCP overwritechattr +i /etc/resolv.conf
Arjun, backup admin, ChennaiKeeps ACLs in nightly rsyncrsync -aAX /srv/ nas:/backup/srv/
Mia, web host, SydneyLets nginx enter a home folder without listing itsetfacl -m u:nginx:x /home/mia

13. Common errors and how to fix them

Everyone hits these errors. Knowing the cause saves hours.

Read the exact message first. Then match it to a row below.

Error you seeWhy it happensHow to fix
setfacl: command not foundacl package missingInstall acl.
sudo dnf install -y acl
setfacl: q3.csv: Operation not supportedFile system without ACL support (some FUSE, NFSv3 without acl)Use a supported fs or mount option acl.
findmnt -no FSTYPE,OPTIONS --target q3.csv
setfacl: Option -m: Invalid argument near character 3Wrong syntax, e.g. u-priya:rUse u:NAME:PERMS.
setfacl -m u:priya:r q3.csv
setfacl: Option -m: Invalid argument near character 3 (unknown user)The user name does not existCheck with id.
id priya
User has ACL rw but still cannot write (#effective:r--)Mask lowered, often by chmodRaise the mask.
setfacl -m m::rw q3.csv
New files in shared folder lack team accessNo default ACLAdd a default ACL.
setfacl -d -m g:audit:rX /srv/reports
ACLs lost after copy or restorecp/tar without ACL optionsUse cp -a, rsync -aAX, tar --acls.
rsync -aAX src/ dst/
rm: cannot remove 'x': Operation not permitted (as root)File is immutableCheck and clear the attribute.
lsattr x && sudo chattr -i x
logrotate: error renaming /var/log/app.log: Operation not permittedAppend-only or immutable logClear +a before rotation, set again after.
sudo chattr -a /var/log/app.log
chattr: Operation not permitted while setting flagsNot root, or inside a container without the capabilityRun as root on the host.
sudo chattr +i file

14. Troubleshooting step by step

If access is strange, check normal bits, then ACL and mask, then attributes, then SELinux.

Go top to bottom. Stop at the first step that shows the problem.

  1. See the bits and the +.
ls -l file
  1. Read the full ACL and effective rights.
getfacl file
  1. Check the parent folders too.
namei -l /path/to/file
  1. Look for i or a attributes.
lsattr file
  1. Check the file system supports ACLs.
findmnt -T file
  1. Check SELinux last.
ls -Z file

15. Lab 1: Two teams, one folder

finance owns /srv/reports; audit gets read-only on existing and future files; one contractor gets temporary read.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Set up groups and folder.
sudo groupadd -f finance; sudo groupadd -f audit; sudo useradd -m -G audit aud1; sudo useradd -m contr1; sudo mkdir -p /srv/reports && sudo chgrp finance /srv/reports && sudo chmod 2770 /srv/reports

Output:

(no output)
  1. Give audit read now and later.
sudo setfacl -R -m g:audit:rX /srv/reports && sudo setfacl -d -m g:audit:rX /srv/reports

Output:

(no output)
  1. Create a file and test audit.
echo total=100 | sudo tee /srv/reports/q4.txt >/dev/null && sudo -u aud1 cat /srv/reports/q4.txt && sudo -u aud1 sh -c 'echo x >> /srv/reports/q4.txt'

Output:

total=100
sh: /srv/reports/q4.txt: Permission denied
  1. Give the contractor read.
sudo setfacl -m u:contr1:rx /srv/reports && sudo setfacl -m u:contr1:r /srv/reports/q4.txt && sudo -u contr1 cat /srv/reports/q4.txt

Output:

total=100
  1. Remove the contractor.
sudo setfacl -x u:contr1 /srv/reports /srv/reports/q4.txt && sudo -u contr1 ls /srv/reports

Output:

ls: cannot open directory '/srv/reports': Permission denied

16. Lab 2: Protect files with chattr

Make one file immutable and one log append-only, prove it, then undo.

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

  1. Create test files.
sudo mkdir -p /srv/lab16 && echo v1 | sudo tee /srv/lab16/conf >/dev/null && echo start | sudo tee /srv/lab16/log >/dev/null

Output:

(no output)
  1. Set attributes.
sudo chattr +i /srv/lab16/conf && sudo chattr +a /srv/lab16/log && lsattr /srv/lab16

Output:

----i---------e------- /srv/lab16/conf
-----a--------e------- /srv/lab16/log
  1. Try to change conf.
echo v2 | sudo tee /srv/lab16/conf

Output:

tee: /srv/lab16/conf: Operation not permitted
  1. Append and overwrite log.
echo line2 | sudo tee -a /srv/lab16/log; echo wipe | sudo tee /srv/lab16/log

Output:

line2
tee: /srv/lab16/log: Operation not permitted
  1. Undo and clean.
sudo chattr -i /srv/lab16/conf && sudo chattr -a /srv/lab16/log && sudo rm -r /srv/lab16

Output:

(no output)

Ravindra Bagale's Tip

When you add an ACL to a shared folder, always add the same rule as a default ACL too (-d), and check '#effective' in getfacl. Most 'ACL does not work' cases are a missing default or a low mask.

17. Frequently asked questions

Q. What does the + in ls -l mean?

The file has an ACL.

Q. Do ACLs replace normal permissions?

No, they add to them. Owner and other bits still apply.

Q. Why does chmod break my ACL?

On a file with an ACL, chmod's group digit sets the mask, which can cut named entries.

Q. Can root bypass chattr +i?

Not without removing the attribute first with chattr -i.

Q. Do ACLs work on NFS and in containers?

NFSv4 has its own ACLs (nfs4_setfacl); container bind mounts keep the host fs ACLs.

Q. Does Windows-style deny exist?

Not in POSIX ACLs. Give fewer rights instead, for example u:sam:---.

Q. Why does chattr fail on XFS for some letters?

XFS supports only some flags (like i and a). Others are ext4-only.

Q. How do I back up ACLs?

getfacl -R > file, or rsync -aAX, or tar --acls.

18. Interview questions and answers

Beginner level

Q. What is an ACL?

An extra list of user and group rights on a file beyond owner/group/other.

Q. How do you read an ACL?

getfacl FILE.

Q. Give user priya read on a file.

setfacl -m u:priya:r FILE.

Q. What does chattr +i do?

Makes a file immutable, even for root.

Mid level level

Q. What is a default ACL?

An ACL on a folder that new files and folders inside inherit.

Q. What is the ACL mask?

The maximum rights for named users, named groups and the owning group.

Q. How do you copy files keeping ACLs?

cp -a, rsync -aAX or tar --acls --xattrs.

Q. chattr +a vs +i?

+a allows only appending; +i allows no change at all.

Senior level

Q. A user has an ACL entry rwx but gets Permission denied. Debug it.

Check #effective (mask), a parent folder's x, the owner entry taking priority, lsattr flags, SELinux, and whether the fs supports ACLs.

Q. Groups vs ACLs: when do you choose which?

Groups for stable role-based access; ACLs for exceptions or multiple teams with different rights on the same tree. Too many ACLs are hard to audit.

Q. Could an attacker with root defeat chattr +a logs?

Yes, root can clear the flag, so ship logs off the box (remote syslog/SIEM) as well.

Q. How do you migrate a share and keep all rights?

rsync -aAXH --numeric-ids, same UIDs/GIDs on both sides, then compare getfacl -R outputs.

Try at home

  1. Create a folder where your friend user can read but not write, without adding them to any group. Prove it with getfacl and a write test.
  2. Make a file immutable, try to delete it as root, then unlock and delete.

Practise this chapter

Interview questions and answers

Why does a named user’s rwx entry sometimes show effective r-x?

The ACL mask limits the extra named users and groups. Read the mask alongside that entry. Here the mask removes write from the effective result, so opening a file to read can work but writing may be denied. Check the existing mask before changing it because it can affect several entries.

Check your understanding

Choose an answer, then compare your reasoning with the explanation.

0 of 3 answered correctly
1. What does a default ACL on a directory normally do to a file already there?

Answer and explanation

A. Leaves the existing file’s access ACL unchanged

A default ACL provides a pattern for newly created entries. Set access ACLs on older files separately where needed.

2. Which evidence shows the effective rights of a named group after the mask applies?

Answer and explanation

A. getfacl output showing the mask and effective rights

getfacl shows access entries and the mask that limits some of them. The group name by itself cannot reveal how the mask changes the result.

3. Why might a user with a read entry still fail to open the file by path?

Answer and explanation

C. They cannot traverse a parent directory

The system must traverse each directory component before it can reach the file and check its read permission.

Practice Tasks

Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.

About this scenario

Amravati Agro Market is a agriculture business in Amravati. Anjali Thakre looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 17

Easy Read an ACL

ls shows a +.

Show the ACL of /srv/ledger.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy User read access

Auditor visiting BIZ.

Give user kavya read on q4.csv with an ACL.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy See attributes

Root cannot delete a file.

List the attributes of /etc/hostname.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium ACL without header

Compare two files easily.

Show the ACL of q4.csv without the comment header.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Group write access

Audit team edits the file.

Give group compliance read and write on q4.csv with an ACL.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Whole tree, folders get x

Existing files need access.

Recursively give group compliance rX on /srv/ledger.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Default ACL for new files

New files must keep access.

Set a default ACL on /srv/ledger giving group compliance rX.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Remove one user

Contractor left BIZ.

Remove the ACL entry of user contr1 from q3.csv.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Remove all ACLs

Reset a folder.

Remove every ACL entry from old.txt.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Copy with ACLs

Nightly backup at BIZ.

Copy /srv/data/ to /backup/data/ with rsync keeping ACLs and xattrs (archive mode).

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Make immutable

Stop tools overwriting DNS config.

Make /etc/hostname immutable.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Unlock an immutable file

You need to edit it now.

Remove the immutable attribute from /etc/hostname.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Append-only log

Audit trail must not be edited.

Make /var/log/payments.log append-only.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Raise the mask

#effective shows r-- after chmod.

Set the ACL mask of q4.csv to rw.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Remove default ACLs only

Existing entries must stay.

Remove only the default ACL of /srv/ledger.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Back up ACLs to text

Before a migration.

Save the ACLs of /srv/reports recursively into reports.acl.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Let caddy pass through home

Serve ~/public_html without opening home.

Give user caddy only execute on /home/meera with an ACL.

  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

In short

  1. + in ls -l means an ACL.
  2. getfacl reads, setfacl -m adds, -x/-b removes.
  3. Default ACLs (-d) for new files.
  4. Mask caps named entries; chmod can change it.
  5. Keep ACLs with cp -a, rsync -aAX, tar --acls.
  6. lsattr shows; chattr +i locks, +a append-only.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

ACLs in 4 steps. Give one more user access. setfacl -m adds, getfacl reads. Add -d so new files inherit. Read access for one user.
Revision card: ACLs in 4 steps · Download PNG · Open card page
chattr locks. Even root cannot change it. +i immutable, +a append only. lsattr shows the flags. Protect DNS config.
Revision card: chattr locks · Download PNG · Open card page
chmod vs setfacl. Owner, one group, others. / Any number of users and groups.
Comparison: chmod vs setfacl · Download PNG · Open card page
chattr +i vs chattr +a. Nothing: no write, delete, rename. / Only adding to the end.
Comparison: chattr +i vs chattr +a · Download PNG · Open card page
What is the + in ls -l?. The file has an ACL. chmod may not show all access. Read it.
Interview card: What is the + in ls -l? · Download PNG · Open card page
What is the ACL mask?. Max rights for named entries. chmod on group changes the mask. Raise it.
Interview card: What is the ACL mask? · Download PNG · Open card page
New files lose access?. Normal ACLs apply to existing files. Default ACLs pass to new files. Set default.
Interview card: New files lose access? · Download PNG · Open card page
Root cannot delete a file?. It may be immutable. lsattr shows i. Remove the flag.
Interview card: Root cannot delete a file? · Download PNG · Open card page

More cards: Ravi Sir's Cards.