LinuxQuestions.org
Register a domain and help support LQ
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 10-22-2009, 01:25 AM   #1
vijay_babu1981
Member
 
Registered: Nov 2004
Location: india
Distribution: fedora 10
Posts: 82

Rep: Reputation: 19
How to set File Permissions


I have 2 users (A and B) both members of a group called 'newgrp'.
As root, created a directory in "/usr/local/" and named it "temp".
As root, changed the ownership as 'chown -R newgrp /usr/local/temp'
Changed the permissions 'chmod -R gau+rwx /usr/local/temp'.

User A and B are able to read and write in temp directory.

But when user A creates a subdirectory as /usr/local/temp/sub, User B is not able to write in that subdirectory. This is because the permission is not set properly for this new subdirectory. It allows only A to write.

Can anyone tell me how to set the permissions so that both A and B can create new subdirectories and enjoy the privilege of read and write in subdir created by each other.

Regards
 
Old 10-22-2009, 01:39 AM   #2
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
Does this work?
Code:
chmod -R 777 /usr/local/temp
 
Old 10-22-2009, 01:41 AM   #3
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
Try 'chmod g+s /usr/local/temp', you'll need to reset the group ownership manually on directories that have already been created though

cheers
 
Old 10-22-2009, 01:44 AM   #4
vijay_babu1981
Member
 
Registered: Nov 2004
Location: india
Distribution: fedora 10
Posts: 82

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by cola View Post
Does this work?
Code:
chmod -R 777 /usr/local/temp
I think this is same as chmod -R gau+rwx /usr/local/temp
Code:
777 = gau+rwx

My problem is that anything created in /usr/local/temp by either A or B is owned by him. Probably I want the ownership to be of the group even when A or B creates a file/directory. Group ownership will ensure that both will be able to r/w.

Regards,

Last edited by vijay_babu1981; 10-22-2009 at 02:08 AM. Reason: each 7 is for g, a and u
 
Old 10-22-2009, 01:55 AM   #5
vijay_babu1981
Member
 
Registered: Nov 2004
Location: india
Distribution: fedora 10
Posts: 82

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by kbp View Post
Try 'chmod g+s /usr/local/temp', you'll need to reset the group ownership manually on directories that have already been created though

cheers
Nope, it doesnt work. Man chmod says that 's' will set the user/group id on execution. Dont know how that can help. There is another option in the man page 't' for sticky. Trying that out.

Regards
 
Old 10-22-2009, 02:07 AM   #6
rkski
Member
 
Registered: Jan 2009
Location: Canada
Distribution: CentOS 6.3, Fedora 17
Posts: 247

Rep: Reputation: 51
Hi
Code:
chmod g+s /usr/local/temp
as kpb pointed out, that will set the group ID bit(SGID) on the group which is what you want. that way files created in that directory will be owned by the group.

same as #chmod 2777 /usr/local/temp

Last edited by rkski; 10-22-2009 at 02:13 AM.
 
Old 10-22-2009, 02:13 AM   #7
vijay_babu1981
Member
 
Registered: Nov 2004
Location: india
Distribution: fedora 10
Posts: 82

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by rkski View Post
Hi
Code:
chmod g+s /usr/local/temp
as kpb pointed out, that will set the sticky bit on the group which is what you want. that way files created in that directory will be owned by the group.

same as #chmod 2777 /usr/local/temp

Hi rkski,

Am i reading the man page incorrectly? 5th para of the man page says that 's' will set the user or group id on execution. 't' is for sticky.

Now do I want sticky? Or do i want to set the user/group id on execution?

BTW, what is meant by setting the user/group id on execution? Is 'mkdir subdir' an execution?

(I am trying out both 't' and 's' again. separately)

Regards,

Last edited by vijay_babu1981; 10-22-2009 at 02:16 AM. Reason: Clarifying the question 'mkdir subdir'
 
Old 10-22-2009, 02:19 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
You're confusing dirs with files. For a dir, its r = read, w = write, x = search; and yes, altering the 'x' to 's' via chmod g+s is indeed what you want.
BTW, you do know that 'newgrp' is a Unix cmd http://linux.die.net/man/1/newgrp ? I would NOT recommend it for a group name, to avoid (even more) confusion.
 
Old 10-22-2009, 02:22 AM   #9
rkski
Member
 
Registered: Jan 2009
Location: Canada
Distribution: CentOS 6.3, Fedora 17
Posts: 247

Rep: Reputation: 51
hi
when you set the SGID bit for a directory any files created in that directory automatically have their group ownership set to that of the group owner of the directory.
 
Old 10-22-2009, 02:36 AM   #10
vijay_babu1981
Member
 
Registered: Nov 2004
Location: india
Distribution: fedora 10
Posts: 82

Original Poster
Rep: Reputation: 19
Hi

Thank you all for helping. chmod -R g+s /usr/local/temp works.

It preserves the group ownership whenever any new file or directory is created.


Quote:
chrism01: you do know that 'newgrp' is a Unix cmd
Hi chrism01,
I did not know that newgrp was a Unix cmd. But all these names I used in the post are imaginary, actual names I am using are different and fortunately I am not using newgrp as a name for a group. Infact I am trying to create a CVS server and the group name is cvsgroup.

Regards,
 
  


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
file permissions with Set GID cylon Linux - Newbie 2 09-16-2009 07:49 PM
Gnome can't set file permissions Itsamnaaj Linux - Software 8 04-29-2009 10:49 AM
How to set file permissions using SFTP client thesignchef Linux - Server 3 04-27-2009 01:00 PM
Where to set default file permissions (umask)? tredegar Linux - Newbie 14 01-27-2004 06:10 PM
How to set correct file/directory permissions pat.delaney Linux - Networking 5 12-02-2003 10:39 AM


All times are GMT -5. The time now is 10:15 PM.

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