Question is about user permissions in RedHat. How to give read-only permission to specific user just to read a specific folder and its sub-folders and files?

How can I do it?

I've tried: chmod a+r -R folder but it doesn't work - permission is still denied.

So, the situation is, I work under root, I have:

  • user1
  • user2

I need to give user2 an opportunity to read-only folder and all files and sub-folders of user1.

How can I do that?

I've tried: chmod user2 r -R user1 but it doesn't work either.

It still has permission as denied.


Assuming that user1 is the owner of the folder, and has full permissions over it, it might be best to handle it by chowning the folder to be owned by user1, and owned by a group that user2 belongs to. Something like the below would work:

# usermod -a -G somegroup user2
# ls -l | grep ExampleFolder
drwxr-xr-x 2 root root    4096 Dec 25 23:32 ExampleFolder
# chown -R user1:somegroup ExampleFolder
# ls -l | grep ExampleFolder
drwxr-xr-x 2 user1 somegroup    4096 Dec 25 23:32 ExampleFolder

Now user2 has only read and execute permissions to ExampleFolder. Further changes to permissions are possible by simply doing chmod for that group.

user2@linux:/opt$ cd ExampleFolder/
user2@linux:/opt/ExampleFolder$ ls
user2@linux:/opt/ExampleFolder$ touch somefile
touch: cannot touch `somefile': Permission denied

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.