Saturday, May 11, 2013

How to apply ACL (Access Control List) for a file?


What is ACL (Access Control List)?


We all know that by default every file contains permissions for the owner, group and other(world). If we want to set something like read only for 1 user, read/write for a group, read/write/execute for another set of users for a particular file, then We can use ACL.


We can use the below commands to do the ACL for a file.

aclget  - To display ACL for a file
acledit - To edit the ACL for a file
aclput  - To set the ACL for a file using a ACL control file

Few examples,

Let us take file1 as the target file.

To display the current ACL values for file1,
# aclget file1

To edit the ACL for a file,  (How to apply acl for a file)
# acledit file1

This will open a editor with ACL values showing some values like below

attributes: SUID
base permissions:
   owner  (frank): rw-
   group (system): r-x
   others        : ---
extended permissions:
   disabled

If you want to enable and set ACL values, just change the stanza "extended permissions" like below

attributes: SUID
base permissions:
   owner  (frank): rw-
   group (system): r-x
   others        : ---
extended permissions:
enabled
       permit    rw-    u:user1
       deny      r--    u:user2, g:group1
       permit    rw-    g:user3, g:group2