Access Control List (ACL) provides a more flexible way to define file and directory permissions beyond the traditional owner-group-other model in Linux. ACLs allow administrators to assign specific access rights (read, write, execute) to individual users or groups, ensuring finer control over permissions.
- Assign specific permissions to multiple users or groups for the same file or directory.
- Extend beyond standard rwx permissions for more complex access control scenarios.
- Allow finer-grained control over permissions when the default owner-group-other model is insufficient.
Ensure the file system supports ACL (e.g., ext4, xfs).
- Remount the file system with ACL support:
mount -o remount,acl /mount_point
- To make this change persistent, edit
/etc/fstab:/dev/sda1 / ext4 defaults,acl 0 1
Use the getfacl command to check ACL settings:
getfacl filename# file: filename
# owner: root
# group: root
user::rw-
user:john:rw-
group::r--
mask::rw-
other::r--
Assign permissions to a specific user using setfacl:
setfacl -m u:username:permissions filenameGrant read and write permissions to user john for myfile.txt:
setfacl -m u:john:rw- myfile.txtAssign permissions to a specific group using setfacl:
setfacl -m g:groupname:permissions filenameGrant read-only access to the developers group for myfile.txt:
setfacl -m g:developers:r-- myfile.txtsetfacl -x u:username filenameRemove ACL for user john:
setfacl -x u:john myfile.txtsetfacl -b filenameDefault ACL ensures that new files or subdirectories inherit specified permissions.
setfacl -m d:u:username:permissions directoryEnsure all new files in /shared_directory allow john to read and write:
setfacl -m d:u:john:rw- /shared_directoryACL permissions follow the standard rwx model:
| Permission | Meaning |
|---|---|
r-- |
Read-only |
rw- |
Read and write |
rwx |
Read, write, and execute |
# Grant user 'john' read and write permissions to 'report.txt'
setfacl -m u:john:rw- report.txt
# Verify ACL
getfacl report.txt# Grant group 'team' read-only access to the directory
setfacl -m g:team:r-- /data/projects
# Verify ACL
getfacl /data/projects# Ensure all new files in '/data/shared' allow 'john' to read and write
setfacl -m d:u:john:rw- /data/sharedACLs in Linux provide a powerful method for fine-grained access control over files and directories. They extend the traditional permission system, allowing administrators to manage complex access scenarios efficiently. By implementing ACLs, system administrators can improve security and access management in multi-user environments.