To understand the workings of ACLs, let's follow these steps:
- We will first check the default ACL values for any file or directory. To do this, we use the getfacl command:
- Now, to set an ACL on file1.txt, we will use the following command:
In the preceding command, we have given rwx access to the root user for the file1.txt file.
When we check again using getfacl, we can see the new ACL values.
- Run the given command to confirm ACL setup on file1.txt:
The (+) sign after the file permissions confirms it has the ACL set up.
- We can also set an ACL on a folder recursively, by using the setfacl command. First, we will check the default ACL for our dir1 directory, using getfacl:
- Now, let's add rwx access to the dir1 directory using setfacl:
- We can now confirm that the ACL is set up on the directory using the given command:
- Now, let's check the ACL for the user1 group on file1.txt:
- Let's set rwx access to the group user1 on file1.txt: