Home Linux How to configure ACL (Access Control List) on Linux

How to configure ACL (Access Control List) on Linux

Key Points:

1.Configure ACL (Access Control List) on Linux.
2. Create a new Acl, modify or remove ACL.

ACL (Access Control List)

We know how to add a users to a group but if we do not want to add user in a group and want to allow some permissions to user on directory, how can we do that?? Then need to configure ACL on linux. Two types of ACL are:

  1. Access ACL – Can be used on any file or directory.
  2. Default ACL – Used on giving or setting ACL on a specific directory. These are optional and used with ‘-d’ option.

How to Check default ACL

Use command getfacl to check default ACL.

[arun@localhost ~]$ getfacl centos/
ACL getfacl command outputACL getfacl command output

Configure ACL

setfacl command used for creating ACL. It is indicated by ‘+’ sign .To create a ACL for a user, syntax is:

setfacl -m u: arun:rw centos/

setfacl : set ACL
-m : To modify or create new ACL
u : used for user
arun : username
rw : permission allow
centos/ : file or directory path

[arun@localhost ~]$ setfacl -m u:arun:rw centos/
Create new ACL cmd outputCreate new ACL cmd output

You can also set ACL for a group:

setfacl -m g:group:rw path of a file

How to remove all the ACL from a file/directory

To remove all the ACL from file/directory, -b argument used.

[arun@localhost ~]$ setfacl -b centos/

Remove specified ACL from a file/directory

Argument ‘-x’ used for this:

 [arun@localhost ~]$ setfacl  -x  u:arun:rw centos/ 

Congratulations !! you have successfully learned how to create or remove ACL (Access Control List) on Linux.


Please enter your comment!
Please enter your name here