Two groups that have different permission to the same directory - it's possible?
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.
Two groups that have different permission to the same directory - it's possible?
Hello everybody.
Example:
Two groups (g1, g2) are configured in system. It is possible that these groups have different permissions to the same directory? For example g1: r-x g2: rwx. It is possible to resolv this problem?
Originally posted by bikov_k it is possible if one group is the owner group and then the other group is just something else. But I guess that wont work for you. hm!
g1 is a group of people that would like to write/read files in /home/share (for example) directory.
g2 is a group of people that would like to only read files in /home/share directory.
Nobody else (others for example) should have any permissions to this directory.
Quote:
bikov_k Why do you want to have two groups with different permissions?
I would like to have two groups of people. One that would have read/write permission to the specific directory, other that can only read from that directory. No one else should have rwx permissions to that directory.
if you want you can use chmod 774 though it doenst create a permission
for the g2 it will set a permission read,write and execute permissions
for the user read, write and execute for the group and only read permission for
other users. only a suggestion! £Ä3
Originally posted by bikov_k it is possible if one group is the owner group and then the other group is just something else.
But I guess that wont work for you.
Have I missed some context? I don't see why this shouldn't work for you.
Let the folder be owned by the group that needs "rwx" access, and configure it to be "rx" by other groups. This means that *everybody*, not just your "g2", will get "rx" access, maybe that's what bikov_k meant.
Originally posted by KlaymenDK Have I missed some context? I don't see why this shouldn't work for you.
Let the folder be owned by the group that needs "rwx" access, and configure it to be "rx" by other groups. This means that *everybody*, not just your "g2", will get "rx" access, maybe that's what bikov_k meant.
O well, I tried.
If you give permission that you wrote:
Code:
d---rwxr-x 4 user g1 1024 2004-10-21 17:52 share
not only g2 can read from that directory. Any user on the system can read files from that directory (it's not good for security reasons) . I would like, that only g1 and g2 can read from that directory. Additional I would like to give write permissions to g1. I suppose that this isn't possible in Linux system. Am I wrong?
The only way I can think to do this involves an sudo, which I don't know if you are in favor or familiar with. Here's my thought:
[list=1][*]Add all members of both groups to a new (third) group[*]Set the group for this directory to this new group (chgrp newGroup /some/dir)[*]Set the permissions to 750 for the directory[*]Set up an SUDO for the members of g1 to use to be able to write to the directory as the owner of the directory
Add something like this with visudo
You may want to set up an alias for the members of g1 to use so they won't have to type in a long command to be able to modify a file in that directory.
alias visharedfile='sudo -u USERTORUNASFROMSUDO /path/to/vi'[/list=1]
Originally posted by looseCannon The only way I can think to do this involves an sudo...
It's clever. One disadvantage is that we have to give permission to every command that group %g1 will use. But I think that vi, cp, mv should be enough. Thank you for advice!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.