LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-26-2012, 12:36 PM   #1
caiphn
LQ Newbie
 
Registered: May 2012
Posts: 15

Rep: Reputation: Disabled
Permissions for a Directory depending on what group (GID) user is in


Hi I'm running: Linux version 2.6.16.60-0.59.1-smp (gcc version 4.1.2 20070115 (SUSE Linux)) #1 SMP

Not sure if that's relevant or not. Sorry for the eye roller, but I've done some googling and it seems like I want the 'chmod' command, but I can't figure out exactly what I need to do.

I have two user groups, 4100 and 4200.

I want 4100 to have read/write/execute/delete access to a particular directory, and I want 4200 to only have read access to a directory. I've been fighting this for a couple of hours, I'd appreciate some direction.
 
Old 05-26-2012, 12:50 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,445

Rep: Reputation: Disabled
A directory in Unix can only be owned by one group. If the directory is owned by 4100, you can give that group r/w/x permissions, but members of 4200 would then have the same rights as every other non-member of 4100.

The above is true for the standard Unix permission model, and it cannot handle a scenario like the one you presented. What you probably want, is a filesystem feature called Access Control Lists (ACLs). man mount and man fstab will tell you how to enable ACLs on your filesystem, and man setfacl will tell you how to create and manipulate ACLs.
 
1 members found this post helpful.
Old 05-26-2012, 12:50 PM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,349

Rep: Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747
it looks easy. Just set the group id 4100 to that particular directory, and set full permission to the group and set read permission to others.
 
Old 05-26-2012, 12:54 PM   #4
caiphn
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Ser Olmy: Thank-you for the response, the second response I got seems to be the more quick and dirty approach that I'm looking for here.

Quote:
Originally Posted by pan64 View Post
it looks easy. Just set the group id 4100 to that particular directory, and set full permission to the group and set read permission to others.
How do I go about doing that?
 
Old 05-26-2012, 01:04 PM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,349

Rep: Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747
you need to use chmod to change/set permissions and chgrp to change group







_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
Old 05-26-2012, 01:09 PM   #6
caiphn
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
[QUOTE=pan64;4688267]you need to use chmod to change/set permissions and chgrp to change group


OK. When I go through chmod manual pages, I'm not sure exactly what I'm looking for to accomplish this. I understand this is some serious hand holding, but how exactly do I do this? The directory is already the appropriate group.
 
Old 05-26-2012, 01:17 PM   #7
caiphn
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
would it be 'chmod o+r-wx directoryname'?
 
Old 05-26-2012, 01:20 PM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,349

Rep: Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747Reputation: 2747
you can test it easily I think, as you described it should be ok.









_____________________________________
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
Happy with solution ... mark as SOLVED
(located in the "thread tools")
 
Old 05-26-2012, 03:22 PM   #9
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi caiphn,

for me it was easier to remember the "chmod" values by numbers (octal mode) than letters,
so it goes:
Code:
chmod ugo filename/directory_name

ugo - meaning
User Group Others

and the values for:
r(ead) - 4
w(rite) - 6
e(x)ecute - 5

all enabled - 7
which would then be used in your case like:
Code:
chmod 775 directoryname

775 meaning:
7- read/write/execute - Owner
7- r/w/x - Group
5- eXecute - others (meaning can read the directory)

Last edited by lithos; 05-26-2012 at 03:24 PM.
 
1 members found this post helpful.
Old 05-26-2012, 03:29 PM   #10
caiphn
LQ Newbie
 
Registered: May 2012
Posts: 15

Original Poster
Rep: Reputation: Disabled
Excellent! Thank-you so much for clearing that up for me, lithos!

Quote:
Originally Posted by lithos View Post
Hi caiphn,

for me it was easier to remember the "chmod" values by numbers (octal mode) than letters,
so it goes:
Code:
chmod ugo filename/directory_name

ugo - meaning
User Group Others

and the values for:
r(ead) - 4
w(rite) - 6
e(x)ecute - 5

all enabled - 7
which would then be used in your case like:
Code:
chmod 775 directoryname

775 meaning:
7- read/write/execute - Owner
7- r/w/x - Group
5- eXecute - others (meaning can read the directory)
 
Old 05-26-2012, 04:05 PM   #11
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
No problem,

that's how I remembered,

here is more detailed explanation of permissions in linux.

You will master it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Group permissions: user can't access 770 directory even though a member of group jm34003 Linux - Security 13 05-16-2012 02:03 PM
Group share directory permissions Neruocomp Linux - Server 1 07-08-2010 06:33 PM
user and group names from uid and gid PatrickNew Programming 3 06-02-2007 09:26 PM
Changing a user's group at login depending on the time of day Steve2001 Linux - General 10 10-11-2004 03:29 AM
Script to set different quota depending on User's Group ID TechNett Programming 6 08-09-2004 02:45 PM


All times are GMT -5. The time now is 11:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration