access control list | acl in Linux

Hello, everyone In this Article we are going to learn what is the Access Control List (ACL) in Linux in a very simple and easy step-by-step approach.

access control list

access control list

Access Control List (ACL) is used to assign high-level permission on files/directories. For example, we have one directory /Directory.

And we have three users as user-1 user-2 user-3. And we want to assign.

user-1 – We want to assign only read ( r ) permission on /Directory.

1 . How to assign only read permission for a single user

We can assign r– (only read) permission to the user-1 by using setfacl command.

# setfacl -m u:user-1:r-- /Directory
Screenshot 1 6

When we see the + symbol in the permission section this means that the ACL is set to directory/file

2. How to view the ACL

To view that weather we have assign the ACL on a directory or file we can use the getfacl command.

# getfacl /Directory
Screenshot 2 6

3. Now We want to assign read and executable ( r & x ) permission on /Directory for the user-2.

# setfacl -m u:user-2:r-x /Directory
Screenshot 3 7

4 . Now We want to assign read-write executable ( r,w,x ) permission on /Directory for user-3.

#  setfacl -m u:user-3:rwx /Directory
Screenshot 4 7

When We want to assign different permission to different users soo we need to implement the ACL concept here.

Please note that we get the first priority to ACL only and second priority to the chmod .

5 . How to Remove ACL From the users

To remove the ACL from individual users we can run setfacl command with ( -x ) option to remove the ACL .

# setfacl -x u:user-1: /Directory 
Screenshot 5 7

The user-1 is now not a part of ACL similarly we can remove other user also with the same method

6. How to remove ACL in single command

To remove all the ACL on one go means We want to remove the ACL from all the user then we can use ( -b ) option on setfacl command.

# setfacl -b /Directory 
Screenshot 6 6

How to assign ACL to the group

When we create a group name as testacl and we added 2 members to the group user-1 user-2.

Now we want to apply the ACL on the testacl group and we want that same permission is applied to user-1 and user-2 members as rwx.

Screenshot 7 5

7 How to assign ACL to the group

To set the permission as rwx on the testacl group we can add ( -m ) option with g option and groupname with the setfacl command.

#  setfacl -m g:testacl:rwx /Directory
Screenshot 8 4

8 . How to Remove ACL from the group

To remove the ACL from the group then we can execute the setfacl command with the ( -x ) option.

# setfacl -x g:testacl
Screenshot 9 4

Conclusion

If you want to learn Linux in the most simple language then please click on this link.

This is the complete Introduction on Access control list ( ACL ) Linux if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on the DevOps Articles

Leave a Comment