File/Directory Access Control List (FACL)
File/Directory Access Control List (FACL)
ACL Benefits:
With ACLs, you can grant permissions to multiple users and groups, identified by
user name, group name, UID, or GID, using the same permission flags used with
regular file permissions: read, write, and execute.
It is used by the owner of a file or a directory to grant or deny specific user access.
Linux capability, can set ACLs on any file or directory. New files and
subdirectories automatically inherit ACL settings from the parent directory's
default ACL.
For Example:
Ali needs to give read permission to Samir which is in marketing group to file1.txt
Before using ACL for a file or directory, the partition for a file or a directory must
be mounted with ACL and support the ACL. By default XFS file system support
the ACL.
If the File System did not support ACL, you can use this command:
Then add the mount point to the /etc/fstab with the option defaults,acl
Note: the . in file1.txt means that there is no acl applied here, but selinux takes the
control of the file.
The command that is used to show details of ACL in file or directory:
If the ACL applied so it will be shown like the following + sign which means this
file have ACL.
To set ACL:
We set ACL entry on a file or directory by using setfacl command:
See Manual:
To remove the user entries from the file:
Note: The default behavior of setfacl is to recalculate the ACL mask entry, unless
a mask entry was explicitly given.
Note: If the uid or gid for a user or group name changes, the ACLs are not changed
to reflect the new uid or gid.
To make the acl applied to all old files in the directory or the subdirectories, not
only to file1.txt, we use the recursive option:
To set the acl to any newly created file in the directory (inheritance), we use the
default permission: