The acl command is used to manage Access Control Lists (ACLs) on Linux systems. ACLs are a way to give more fine-grained control over permissions for files and directories beyond the standard file permissions.
At first I didn't understand so well what this was about, but after using it and reading more about it, I have discovered how to truly appreciate the opportunities coming with Access Control Lists.
Here are some examples of how to use the acl command:
View the ACLs for a file:
$ getfacl filename.txt
View the ACLs for a directory and all of its contents:
$ getfacl -R /path/to/directory/
Set an ACL on a file or directory:
$ setfacl -m u:username:rw filename.txt
This sets read and write permissions for the user username on the file filename.txt.
Remove an ACL from a file or directory:
$ setfacl -x u:username filename.txt
This removes any ACLs for the user username on the file filename.txt.
Copy the ACL from one file to another:
$ getfacl filename1.txt | setfacl --set-file=- filename2.txt
This copies the ACL from filename1.txt to filename2.txt.
Modify an existing ACL:
$ setfacl -m u:username:rwx filename.txt
This adds read, write, and execute permissions for the user username on the file filename.txt.
These are just a few examples of how to use the acl command in Linux. For more information, you can refer to the manual pages (man acl) or the official documentation.