How to give read-only permission for specific user for specific folder in RedHat
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to give read-only permission for specific user for specific folder in RedHat
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 user2 give 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
and it doesn t wotk either.
It still has permission as denied.
Then user2 will have the same rights as user1, which I don t want. User2 should not be able to do anything with files in user1 folders, only to read.
I also can give ALL other users than user1, permission to read.
How to do that?
Hi. What RH version and DE? Many times you can right click on a folder and go to a permission tab with check boxes... best wishes and have fun. But, don't do this.
Last edited by jamison20000e; 12-24-2013 at 10:04 AM.
Then user2 will have the same rights as user1, which I don t want.
No they won't, they'll only be able to do what you let them do with the group permissions. Presumably user1 would be the owner of the files/dirs, which has its own set of permissions.
Quote:
Originally Posted by digitalbiopharm
User2 should not be able to do anything with files in user1 folders, only to read.
Which is why I said to remove group write access from the files/dirs.
Quote:
Originally Posted by digitalbiopharm
I also can give ALL other users than user1, permission to read.
How to do that?
For that you would just grant read access for files and read/execute access for dirs for "other".
Each file and dir has an owner and a group. These do not necessarily have to be the same (and often aren't). Each file/dir also has read, write, and execute permission for three separate entities. The owner of the file has its own rwx set of permissions, any members of the same group have their own rwx set of permissions, and "everybody else" has their own rwx set of permissions.
When you use chmod, you can explicitly set the permissions for each entity separately.
Read access is a 4
Write access is a 2
Execute access is a 1
Add the access you want to get a number between 0 and 7. Then you can use chmod to set it for all entities like so:
Code:
chmod 750 file
That will give "7" (read/write/execute) permission to the owner, "5" (read/execute but not write) to any members of the same group, and "0" (no access) to everybody else.
Last edited by suicidaleggroll; 12-24-2013 at 10:07 AM.
@mddesai: Nice; I like that tree command unless in a largely populated directory as far as "self-explanatory" for the in me, somethings will need digging but in Linux I won't brake my back, awesome.
Last edited by jamison20000e; 12-24-2013 at 04:18 PM.
Read access is a 4
Write access is a 2
Execute access is a 1
Add the access you want to get a number between 0 and 7. Then you can use chmod to set it for all entities like so:
Code:
chmod 750 file
That will give "7" (read/write/execute) permission to the owner, "5" (read/execute but not write) to any members of the same group, and "0" (no access) to everybody else.
Sure, but that would grant execute permissions to all of the files. I usually do it in two passes using find, first for the dirs, and then for the files
Code:
find folder -type d -exec chmod 750 "{}" \;
find folder -type f -exec chmod 640 "{}" \;
Of course you'd have to go back and add execute permission to any files that are supposed to have it.
Protection from writing, means also that files cannot be deleted, or copied etc., right?
So, just read and executed? Then I ll just make it recursively.
They can be copied, since all copying requires is reading. They just can't be deleted, edited, or overwritten without write permission. You shouldn't add execute permission to files that don't need it though.
750 permission means the file's owner can read/write/execute and any members of the file's group can read/execute. Was the other user you tested a member of the file's group?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.