0

Need to give new user acl permissions on linux server without changing existing chmod permissions. New user doesn't belong to any group and doesn't own files. User needs to be able to write and read files. Need to use effective permissions when providing write & read to files. The folders need to have read and execute acl permissions for this user. The problem I'm facing is that when I change the file acl permissions using -R, it changing the folders too. I don't need/want that. How do I apply the acl permissions below for ALL files (those in sub-directories too) without changing folder permissions?

The new users needs to have write permissions to a file, which means the user needs to have read+exe permission on the containing folder and read+write permission on the file.

# assigned read + execute to all the folders on server (includes subfolders)
setfacl  -m user:robinhood:r-X  /server/root/

assign read + write to ALL the files (not folder) on server

set file permissions using effective permissions

this assigns file permissions to all files in root directory, but not files in all subfolders.

What's the best way to apply the command to all the files

including those in subdirectories and not to the folders?

The folders are not to have effective permissions.

setfacl -m mask:rw-,user:robinhood:rwx /server/root/*

yaris
  • 43

1 Answers1

0

find is your friend:

find /server/root -type f -execdir setfacl -m mask:rw-,user:robinhood:rwx {} \;

This command finds all files in /server/root of type file (-type f) and executes this command in the file's directory:

setfacl -m mask:rw-,user:robinhood:rwx {} \;

where {} is a placeholder for the current item in find's list of results and \; marks the end of -execdir's parameter.

It takes a little bit more time but only sets the ACL on files and nothing else.

If you need to modify the ACL of the subdirectories of /server/root for robinhood to access the subdir's content, just use find -type d and edit the setfacl command accordingly.

MasinAD
  • 11