Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


setfacl command
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

setfacl command

If we need to set advanced/particular permission to a folder or a set of folders other than normal folder permission of 755 for directories , we can use access control lists (ACL)

We can use below bash script to set the particular permission for a set of folders

===

dir='dir1,dir2,dir3'

for d in $dir
do
( cd $d && setfacl -m d:o:rwx folder/ )
done

==

First we need to assign the folder names in the variable dir.

setfacl -m d:0:rwx folder/

This command will modify the permission of others category to rwx for the directory folder/ in all directories of the variable dir.

If you experience any error like

operation not supported/permitted

tune2fs -o +acl /dev/sda1(the disk/partition where those directories belong)

the above command will include acl option in the filesystem for that particular partition.

then remount it

mount -a

-------------------------------------##############---------------------------

Comments

  • mkshmksh Member

    Uh, well, OK? So setfacl actually sets ACLs right?

  • @mksh said:
    Uh, well, OK? So setfacl actually sets ACLs right?

    setfacl is usually used to set ACL's on a file if the target filesystem supports extended attributes. Most modern Linux filesystems supports xattrs nowadays, so you can easily take the OP's example and set the ACL's that way.

    Usually a remount with attrs option would enable extended attributes, but that works too by running tune2fs...

  • jsgjsg Member, Resident Benchmarker

    I particularly like the mount -afor remounting.

    (Correct: mount -o remount [mount point])

    Thanked by 2bootstrap mksh
Sign In or Register to comment.