LinuxQuestions.org
Review your favorite Linux distribution.
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 03-17-2010, 08:07 AM   #16
Zuulie
LQ Newbie
 
Registered: Mar 2010
Location: London
Distribution: Ubuntu
Posts: 16

Rep: Reputation: 1

Wow. This was an interesting and unexpected first experience of this forum.

So, the command has been corrected as 'egrep' was deprecated according to the man page.

Let's correct the rationale as well:
Quote:
To prevent more results than the intended to be returned, the following, more explicit, expression should be used.
 
Old 03-29-2010, 01:19 PM   #17
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by sayan_acharjee View Post
Try this:#usermod -G Marketing username
Tried it and the only group user now belongs to is 'Marketing'. All other group memberships have been removed. Debian Lenny. Any suggestions how I rescue situation?
 
Old 03-29-2010, 04:44 PM   #18
Bratmon
Member
 
Registered: Jul 2009
Location: 75.126.162.205:80
Distribution: Arch / Mint 17
Posts: 297
Blog Entries: 3

Rep: Reputation: 50
Quote:
Originally Posted by lugoteehalt View Post
Tried it and the only group user now belongs to is 'Marketing'. All other group memberships have been removed. Debian Lenny. Any suggestions how I rescue situation?
Try
Code:
man usermod
I found the answer in less time than it took to make this post.
 
Old 03-29-2010, 08:00 PM   #19
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by Bratmon View Post
Try
Code:
man usermod
I found the answer in less time than it took to make this post.
You misunderstand. My point was that, with hind sight foolishly, I just did the usermod -G thing. I did it because I could not get the user added to the scanner group.

This was because I was adding ':username' to the end of the scanner line in /etc/group. It should have been ',username'. This is only if there is another name(s) on the end of the line, the first name is indeed seperated by a : .

I was, moderately, complaining about being buggered up in this way.

My point was it is difficult to work out which groups the user should belong to given that all this information has been destroyed.

I was warning people who read this post not to use the idiotic usermod -G command.

So to be bloody idiotic: I am in the right and you are in the wrong.
 
Old 03-29-2010, 11:47 PM   #20
itsbrad212
Member
 
Registered: Nov 2009
Location: Chicago
Distribution: Arch and OpenBSD
Posts: 104

Rep: Reputation: 19
Not that hard. Could have been solved with a simple google search:

Code:
usermod -a -G group_name user_name
 
Old 03-30-2010, 10:16 AM   #21
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by itsbrad212 View Post
Not that hard. Could have been solved with a simple google search:

Code:
usermod -a -G group_name user_name
Right, just once more: Using usermod -G removes all existing groups from the user. The above advice in this thread is therefore dangerous and wrong. That is the point I am making.
 
Old 03-30-2010, 07:07 PM   #22
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Disagree
Quote:
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.
http://linux.die.net/man/8/usermod
See 2nd sentence....
 
Old 03-30-2010, 08:28 PM   #23
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by chrism01 View Post
Disagree

http://linux.die.net/man/8/usermod
See 2nd sentence....
Yes I know but the above thing says 'usermod -G' i.e. no '-a'. So it removes the user from all pre-existing groups. That's all I'm saying. Someone reading this thread might, as I did, do usermod -G thinking they would add the user to a group and not realize they would remove the user from all his other groups. My motive in posting is one of service to other Linux users.
 
Old 03-31-2010, 09:50 AM   #24
itsbrad212
Member
 
Registered: Nov 2009
Location: Chicago
Distribution: Arch and OpenBSD
Posts: 104

Rep: Reputation: 19
Quote:
Originally Posted by lugoteehalt View Post
Right, just once more: Using usermod -G removes all existing groups from the user. The above advice in this thread is therefore dangerous and wrong. That is the point I am making.
Correct. I believe the OP of the advice should edit the post and add the correct method of doing it, so if somebody browsing this runs the first command they see, it won't be as dangerous
 
Old 03-31-2010, 12:01 PM   #25
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
Quote:
Originally Posted by itsbrad212 View Post
Correct. I believe the OP of the advice should edit the post and add the correct method of doing it, so if somebody browsing this runs the first command they see, it won't be as dangerous
I feel vindicated.
 
Old 04-01-2010, 01:47 AM   #26
itsbrad212
Member
 
Registered: Nov 2009
Location: Chicago
Distribution: Arch and OpenBSD
Posts: 104

Rep: Reputation: 19
Quote:
Originally Posted by lugoteehalt View Post
I feel vindicated.
Oh, haha I wasn't blaming you
 
Old 04-01-2010, 02:18 AM   #27
prpednek
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: RHEL
Posts: 22

Rep: Reputation: 16
Quote:
Originally Posted by gardenair View Post
thanks for the prompt reply. Well the command works fine. Now a question rises that how can I see all four users in "Marketing " Group. Is there anyway command to check it ?

Hi,
You could have also created the users with the group reference in one commandline.

useradd -g <USER_GROUP> -d <USER_HOME> -c <Some Description> <USERNAME>

This command will only work if the USER_GROUP already exists.
Command to create user group :
groupadd <USER_GROUP>

To answer to your last question, use can use either the 'id' command coupled with the username or grep on the group file as shown.

eg: grep ^<USER_GROUP> /etc/group

eg: id tom
You would need to execute 'id' command for each user.
 
  


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 01:14 PM
how to add a user to a new group? emanresu Linux - Newbie 5 11-21-2005 08:18 AM
add user to group brandnewbie Linux - Newbie 3 08-08-2004 04:53 PM
how to add a user to a certain group? feetyouwell Linux - Software 2 01-13-2004 11:56 AM
how can i add a user to a group? doublefailure Linux - General 14 07-10-2002 11:11 AM


All times are GMT -5. The time now is 11:27 AM.

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