LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-09-2009, 05:56 PM   #1
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 796

Rep: Reputation: 157Reputation: 157
how to share files and directory without group and world access


I want to set up a directory where users from different groups can share files. They all need to be able to view the directory contents, read or edit files, create new files, etc.

These users are in different groups. I don't want to grant world access to the directory or to the files. I want the other access bits set to 0 for the directory and all files created in it.

Is there any way to do this?
 
Old 08-10-2009, 10:57 AM   #2
pljvaldez
Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Squeeze (x86)
Posts: 6,092

Rep: Reputation: 269Reputation: 269Reputation: 269
Why don't you just create a new group for that directory and then only add those people who need it to the group?
 
Old 08-10-2009, 11:39 PM   #3
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 796

Original Poster
Rep: Reputation: 157Reputation: 157
I'm not sure I understand. These users already have a group association, each one different, and they need to remain part of their current group.
 
Old 08-11-2009, 12:20 AM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
An user can belong to as many groups as you need. What you want is to create a new group, let's calle it "my_group", and then add all the relevant users to that group. Then make the following:

Code:
chown root:my_group /whatever/dir 
chmod 770 /whatever/dir
If you are mounting something into that directory, then the ownerships and permissions might depend (or not) in the mount options, only for some fs's.

Last edited by i92guboj; 08-11-2009 at 12:27 AM. Reason: corrected chown command
 
Old 08-11-2009, 12:26 AM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
An user can belong to as many groups as you need. What you want is to create a new group, let's calle it "my_group", and then add all the relevant users to that group. Then make the following:

Code:
chown /whatever/dir root:my_group
chmod 770 /whatever/dir
If you are mounting something into that directory, then the ownerships and permissions might depend (or not) in the mount options, only for some fs's.
 
Old 08-11-2009, 12:29 AM   #6
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 653

Rep: Reputation: 66
You know there is concept of primary and seconday group, a user can belong to one primary but many seconday group. Create a group for that folder, and make users member of that group. Make that group owner of that folder and assign SGID bit to that folder.

#groupadd <nameofgroup>
#chown root:<nameofgroup> path to folder
#chmod g+s <path to folder>
#gpasswd -a <nameofuser> <nameofgroup>
#gpasswd -a <nameofuser> <nameofgroup>
...
Thanks
 
Old 08-11-2009, 07:54 PM   #7
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 796

Original Poster
Rep: Reputation: 157Reputation: 157
Thank you. I must be doing something wrong though, because it doesn't seem to work. The users still get permission denied.

Code:
sar@batcave:/home$ id -a
uid=1002(sar) gid=103(r) groups=7(lp),11(floppy),17(audio),18(video),19(cdrom),83(plugdev),93(scanner),103(r),222(share01)

sar@batcave:/home$ cat /etc/group | grep share01
share01:x:222:sar,fcv,rxf

sar@batcave:/home$ ls -al 
...
drwxr-s--- 10 root share01  4096 2007-07-11 03:58 share/


sar@batcave:/home$ cd share
sar@batcave:/home/share$ touch x.y
touch: cannot touch `x.y': Permission denied
 
Old 08-11-2009, 10:40 PM   #8
vishesh
Member
 
Registered: Feb 2008
Distribution: Fedora,RHEL,Ubuntu
Posts: 653

Rep: Reputation: 66
Your group doesn't seem to have write permission
use
:/home$chmod 775 share

thanks
 
Old 08-11-2009, 10:49 PM   #9
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 796

Original Poster
Rep: Reputation: 157Reputation: 157
That did it. I don't know how I managed to overlook that. Thank you vishesh.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to process a group of files (whole directory, wildcards etc.) garrettderner Linux - Newbie 11 07-31-2008 08:15 PM
Renaming group of files within one directory DIRdiver Linux - General 3 10-25-2006 09:57 AM
apparent group member can't access directory xuanadoo Linux - Newbie 2 09-14-2006 08:02 PM
setting a group for new files in a directory eantoranz Linux - Security 2 01-18-2005 01:44 PM
How to change owner and group in a directory to include subdir and all files Lakota Linux - General 2 07-15-2004 09:35 AM


All times are GMT -5. The time now is 01:19 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration