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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-29-2009, 02:32 PM
|
#1
|
|
Member
Registered: Dec 2004
Posts: 40
Rep:
|
changing default file permissions upon file creation
Hi.
I just created a new user 'john' using this command: useradd -G developers john. So now john belongs to a group 'developers'.
i set john's umask to 0002 so that members of the group developers edit the files.
problem.
when john creates a file, it creates with 'john' as the owner and the group. thus it looks like this:
-rw-rw-r-- 1 john john 0 Sep 29 13:54 text.txt
Q? How can I set his account so that when he creates a file the file created belongs to the group developer instead of john. Eg.
-rw-rw-r-- 1 john developers 0 Sep 29 13:54 text.txt
The /etc/groups file reveals that 'john' does below to the group.
developers:x:503:marry,joel,mk,john
The /etc/passwd file reveals this information:
john:x:504:505::/home/john:/bin/bash
Finally issuing this command 'id john' gives me this:
uid=504(john) gid=505(john) groups=505(john),503(developers) context=user_u:system_r:unconfined_t
what am i doing wrong or what am not doing?!
thank you.
Ps. I am using RedHat linux.
Last edited by ceci2; 09-29-2009 at 02:41 PM.
|
|
|
|
09-29-2009, 02:45 PM
|
#2
|
|
Member
Registered: Sep 2009
Posts: 110
Rep:
|
I would suggest to set up or modify the john account so that it belongs to the developer group by default, unless you really need each account to have a group on it's own. This way the developer group would always be used for john's new files.
Last edited by AngTheo789; 09-29-2009 at 02:46 PM.
Reason: typo
|
|
|
|
09-29-2009, 02:50 PM
|
#3
|
|
Member
Registered: Dec 2004
Posts: 40
Original Poster
Rep:
|
Never mind. I fixed it. Creating a user with '-G' screwed it up.
To fix it I had to do:
# usermod -g developers john
notice the '-g'.
|
|
|
|
09-29-2009, 08:02 PM
|
#4
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 15,026
|
Difference between primary and secondary groups...
Incidentally, to create a shared dir with that property, it's usually best to create a specific user & group, create the home dir, then chmod g+s on the home dir.
That will force all files created by the group members in that dir to be owned by the group id.
Not generally a good idea to allow others into your home dir.
|
|
|
|
09-29-2009, 11:09 PM
|
#5
|
|
LQ Newbie
Registered: Mar 2004
Posts: 13
Rep:
|
agree to chris, make use of suid(the "g+s" option for chmod) on the dir which you want to share within the group
|
|
|
|
09-30-2009, 07:58 AM
|
#6
|
|
Member
Registered: Dec 2004
Posts: 40
Original Poster
Rep:
|
thank you for the valuable information you have posted.
Q? is it possible that by issuing the "#usermod -g developers john' command I am also allowing entry to the Home directory? How can I secure my Home directory so that no members of the group access it?
I am new so if you can provide a complete example would be very helpful.
Thanks you so much.
C
|
|
|
|
10-01-2009, 01:28 AM
|
#7
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 15,026
|
On a user's home dir, the ownerships that count (ignoring possible acls) are:
u=user (aka owner)
g=group
both taken from his entry in /etc/passwd
eg
ls -ld /home/john
drwxr-xr-x 9 john johns_primary_group 2048 Sep 28 08:34 /home/john
typically.
The drwxr-xr-x means
d = dir
rwx = user has rwx perms
r-x = user's group has r-x
r-x = other/world has r-x
you can remove world perms
chmod o= /home/john
When creating a separate shared group dir as described, you create a new dedicated user/group to own it, so its a different group from anyone's primary group.
Then add the reqd users to the share group.
man chmod, chown; see also chgrp, newgrp
HTH
|
|
|
|
10-01-2009, 07:27 AM
|
#8
|
|
Member
Registered: Dec 2004
Posts: 40
Original Poster
Rep:
|
Awesome! You guys are great.
Thank you.
C
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:13 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|