Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Friday 1 November 2013

Access Control List in linux


Access Control List (ACL) is a list of permissions attached to a file or directory.

Pre-Requisite:

To set ACL for any file or directory, the underlying filesystem should be ACL enabled which you have to mention while mounting the filesystem.

To make it permanent, you need to edit /etc/fstab and add "acl" under options field for the specific filesystem.

Ex:
LABEL=/data             /data                   ext3    defaults,acl        1 2

After modifying the /etc/fstab file, you have to remount the filesystem.

# mount -o remount /data


Now we can start setting the ACL on any file or directory located under /data filesystem.

To set full permission for a user on /data,
# setfacl -m u:user1:rwx /data

To set only read/execute permission for a user on /data/file1,
# setfacl -m u:user1:r-x /data/file1

To set full permission for dba group on /data/oracle directory,
# setfacl -m g:dba:rwx /data/oracle

To set full permission to user1 and group1 on /data directory,
# setfacl -m u:user1:rwx,g:group1:rwx /data

To revoke the ACL for a user on /data,
# setfacl -x u:user1 /data

To view the current ACL values on /data,
# getfacl /data

To revoke write access for all users and groups on a file,
# setfacl -m m::rx /data/file1

Above command will set the mask value as "r-x".

To copy the acl of one file to another,
# getfacl file1 | setfacl --set-file=- file2

You can also use the below method to copy the acl rights between files.

$ getfacl /data/file1 > acls.txt
$ setfacl -f acls.txt /data/file2

No comments:

Post a Comment