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.
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.
|
|
11-30-2009, 08:13 AM
|
#1
|
LQ Newbie
Registered: Sep 2009
Posts: 20
Rep:
|
user is not listed in the group
Ubuntu 9.04
groupadd -g 901 sales
usermod -g 901 myuser
The following is the string from the /etc/group file:
sales:x:901:
Where is myuser?
But I have also another question. When I do this for the normal user I can see that added group at least in the output of the group command (and not in the /etc/group file)
But when I do this for sudoer user I can't see an added group even in the output of the group command (logging as that sudoer user).
Thanks.
Last edited by newk; 11-30-2009 at 08:21 AM.
|
|
|
11-30-2009, 08:35 AM
|
#2
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
usermod -g change PRIMARY group so the group ID (GID) is specified in /etc/passwd for the user rather than in /etc/group. If you don't want to change PRIMARY but rather add to ADDITIONAL groups you'd use usermod -G instead. It will then leave the GID in /etc/passwd unmodified and show the user in /etc/group associated with the group you selected.
|
|
|
11-30-2009, 08:48 AM
|
#3
|
LQ Newbie
Registered: Sep 2009
Posts: 20
Original Poster
Rep:
|
But groups after -G have just replaced previous groups but only primary group has remained (and NEW additional secondary groups). How to ADD new groups to the list.
The following is the quote from the Beginning Ubuntu LTS Server Administration From Novice to Professional, Second Edition by Sander van Vugt:
"Group Ownership
When working with group ownership, you should be aware of how group ownership is handled.
By default, the primary group of the user who creates a new file becomes the group
owner of that file. If, however, the user is a member of more than one group, this default setting
can be manipulated. When a user issues the newgrp command, he can change the primary
group setting on a temporary basis. The following steps show what happens next:
1. Log in as some normal user on your computer. Then use the groups command from a
console window to get an overview of all groups that you are currently a member of.
The primary group is listed first. If you haven’t modified anything for this user, it will
have the same name as your user account. Listing 5-4 is an example of this output.
sander@RNA:~$ groups
sander adm dialout cdrom floppy audio dip video plugdev scanner lpadmin admin
2. From the console window, issue the touch newfile command to create a new file
with the name newfile. Then use ls -l newfile to display the ownership information
for newfile. You will see that the primary group is set as the owner of the file (see
sander@RNA:~$ ls –l newfile
-rw-r--r-- 1 sander sander 0 2007-07-28 10:05 newfile
3. Use su to become root. Then use groupadd to create a new group (for example, use
groupadd -g 901 sales to create a group with the name sales and group ID 901). Next,
as root, use usermod -g 901 youruser to make youruser (the user you used in step 1) a
member of that group. After changing this group information, use exit to close the su
session and become the normal user account again.
4. As the normal user, use groups again to get an overview of all groups you are currently
a member of. The new group should appear now, probably as the last group in the list.
5. As the normal user, use newgrp yournewgroup to set the primary group to your new
group on a temporary basis. You can use the groups command to check this; the new
group should now be listed first. You’ll also see that if you create a new file (use touch
somenewfile), the new group will be group owner of the new file. This ensures that all
users who are members of the same group can do the same thing to this file."
Last edited by newk; 11-30-2009 at 09:32 AM.
|
|
|
11-30-2009, 09:15 AM
|
#4
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
If you're asking how you can put new groups in /etc/group you do that with the groupadd command.
groupadd -g <GID> <groupname>
e.g.
groupadd -g 700 oracle
Would add group named "oracle" with GID of 700.
You could then use the useradd -G oracle <username> to add the user you want to the group.
From the usermod man page on CentOS 5:
Quote:
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no intervening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group. This behaviour can be changed via -a option, which appends user to the current supplementary group list.
|
Notice the sentence I bolded.
You can usually get lots more information about any UNIX/Linux command by typing "man <command>" where command is the one you're interested in e.g. man groupadd
man usermod
Last edited by MensaWater; 11-30-2009 at 09:16 AM.
|
|
|
11-30-2009, 09:26 AM
|
#5
|
LQ Newbie
Registered: Sep 2009
Posts: 20
Original Poster
Rep:
|
Thank you jlightner. But I just did steps from the book (see please my previous edited post, if it doesn't bother you). So what is your opinion about that quotation? I agree with you regarding man pages.
|
|
|
All times are GMT -5. The time now is 07:24 AM.
|
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
|
|