You manage the shared directory /srv/data on a multi-user server. Hundreds of files already exist, and the security team mandates that every member of the project2 group must be able to read and modify all current content and automatically inherit the same permissions on any files or sub-directories that will be created there in the future. Existing ownership and the traditional permission bits for other users must remain unchanged. Which single command accomplishes this goal?
Grant read/write (and execute on directories) to project2 for every item that already exists. That needs an access ACL entry applied recursively.
Ensure that future objects created inside /srv/data inherit the same permissions. That requires a default ACL entry on each directory.
The command setfacl -R -m g:project2:rwX -m d:g:project2:rwX /srv/data performs both actions in one step:
-R walks the entire tree so the rule reaches every file and directory that exists now.
-m g:project2:rwX adds an access ACL giving the group read/write (and execute only on directories, thanks to the capital X) on every object it touches.
-m d:g:project2:rwX adds a default ACL to each directory; any new file or directory created later will inherit that rule automatically.
The other answers fall short:
A command that sets only g:project2:rwX lacks a default ACL, so new items would not inherit the permission.
chgrp -R project2 /srv/data changes ownership instead of adding an ACL and could disrupt existing ownership.
chmod -R g+rw /srv/data manipulates traditional permission bits; it does not provide inheritance and may overwrite current settings.
Therefore, the combined access + default ACL with setfacl is the correct solution.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is an ACL in Linux, and why is it used?
Open an interactive chat with Bash
What is the difference between access ACLs and default ACLs?
Open an interactive chat with Bash
What does the -m option and capital X in the setfacl command do?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .