Changing permissions (read-only) for specific user for specific folder and sub-folders/files in RedHat?

1

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.

Andrey

Posted 2013-12-24T13:50:54.293

Reputation: 11

You will need ACL: try reading here, https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-acls.html

– MariusMatutiae – 2013-12-24T16:13:01.920

Answers

0

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

Karthik Rangarajan

Posted 2013-12-24T13:50:54.293

Reputation: 181