Day 13: Access Control List (ACL)

#devops #90daysofdevops #linux

ยท

2 min read

1.What is ACL?

Access Control List or ACL provides a more flexible permission mechanism for file systems. It allows you to give a more specific set of permissions to a file or directory without changing the base ownership and permission.

Suppose you want to give read or write permission to a user without adding him/her to a group. ACL can help you to do that.

Note: to install ACL in ubuntu you can use "sudo apt install acl"

2.ACL Commands: setfacl & getfacl

The setfacl command is used to add or modify an ACL, whereas the getfacl command is used to display the current ACL settings for a file or directory.

getfacl : The getfacl command displays the access permissions of files and directories with file name, owner, group and the ACLs (Access Control List).

getfacl<file_name>

setfacl : setfacl sets (replaces), modifies, or removes the access control list (ACL) to regular files and directories. It also updates and deletes ACL entries for each file and directory that was specified by path. If the path was not specified, then file and directory names are read from standard input (stdin).

To set ACL permission to user : setfacl -m u:user_name:permissions /path_to_file

-m signifies the modification of permissions for the user specified by user_name

To remove ACL permission from user: setfacl -x u:user: /path_to_file

-x signifies the removal of permissions from the user

To set ACL permission to Group: setfacl -m g:group:permissions /path_to_file

To remove ACL permission from group: setfacl -x g:group: /path_to_file

To remove all ACL permissions: setfacl -b /path_to_file

-m - modification

-x - remove permission

-b - remove all entries

For adding permissions to the user in all the files inside a folder recursively, you can use below command:

setfacl -Rm "entry" <targetfile/folder>

e.g. : setfacl -Rm u:sudipa:rwx my_folder

If this post was helpful, please follow and click the ๐Ÿ’š button below to show your support.

_ Thank you for reading!

_Sudipa

ย