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 11-30-2009, 08:13 AM   #1
newk
LQ Newbie
 
Registered: Sep 2009
Posts: 20

Rep: Reputation: 0
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.
 
Old 11-30-2009, 08:35 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,577
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
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.
 
Old 11-30-2009, 08:48 AM   #3
newk
LQ Newbie
 
Registered: Sep 2009
Posts: 20

Original Poster
Rep: Reputation: 0
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.
 
Old 11-30-2009, 09:15 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,577
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
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.
 
Old 11-30-2009, 09:26 AM   #5
newk
LQ Newbie
 
Registered: Sep 2009
Posts: 20

Original Poster
Rep: Reputation: 0
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.
 
  


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
How to list user in Linux box, add an user to a group! steady_lfcfan Linux - Newbie 12 01-27-2013 02:14 PM
New User will not be listed in /etc/group Orangutanklaus Slackware 5 06-05-2006 05:33 AM
Solaris 9: group won't be listed xpucto Solaris / OpenSolaris 10 02-09-2006 06:51 AM
User and Group Admin: How to tell Who is in What group? Akhran Linux - Newbie 1 11-13-2005 12:16 AM
User listed as logged on, even though he's not fishsponge Linux - Security 4 07-19-2004 10:51 AM


All times are GMT -5. The time now is 04:03 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