Using ACLs Linux Command - Access Control List


 How to use the ACLs command in linux.

 

Using ACLs

Filesystem Access Control List, ACLs command is used to list down in details and set the permissions for the different users and groups which we added for a file or directory.

Let’s see the basics on how to use ACLs command.

Scenario 1: 

For a particular file, need to check or list down the permission for a file in the directory.

Standard Linux Command to view the permission:

# ls -l “2022report.txt” * 

 

  • User: root (Read/Write) Permission
  • Group: root (Read) Permission
  • Others (Everyone): Read Permission

 

To view the detailed permission of different users and groups in Linux for a particular file.

# getfacl 2022report.txt 

(This result will show the file name, user and group, permission associated with the user and group).

 

Scenario 2: 

To set the permission for a file by adding a new user by using the ACL command.

 

# setfacl -m u:jcarol:r 2022report.txt 

  • Setfacl: Command to set the permission.
  • M: Modify the permission.
  • U: user
  • R: readonly permission

 

Standard Linux Command to view the new added permission for the new user:

# ls -l “2022report.txt” * 

+ Sign is the indication of new user has been added to the permission list.

 

To view the detailed permission of newly added user for a particular file.

# getfacl 2022report.txt 

  • getfacl: Command to list the permission.
  • User: jcarol:r - (ReadOnly Access).

Scenario 3: 

To set the permission for a file by adding a new group by using the ACL command.

 

# setfacl -m g:fin_users:rwx 2022report.txt 

  • Setfacl: Command to set the permission.
  • M: Modify the permission.
  • g: group
  • rwx: read/write/execute permission

To view the detailed permission of newly added group for a particular file.

# getfacl 2022report.txt 

  • getfacl: Command to list the permission.
  • group:fin_users:rwx - (Read/Write/Execute Access).

Comments