LinuxQuestions.org
Visit Jeremy's Blog.
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 07-20-2004, 07:28 PM   #1
gjhicks
Member
 
Registered: Jun 2004
Location: Melbourne, Australia
Posts: 47

Rep: Reputation: 15
usermod - add user to group deletes from others


Hi,

I want to add a user to a group but when I use [usermod -G] the user is added to the goup but deleted from the others.

For example:

say a user called Fred is in fred, groups home, office and mail. If I want to add Fred to a group called fax, I executed [usermod -G fax Fred]. Now Fred is only in groups fred and fax.

How can I add a group to a user, without losing the existing group memberships?

Regards,

Geoff.
 
Old 07-20-2004, 07:38 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
From the man pages and I made the part important in BOLD:

-g initial_group
The group name or number of the user's new initial
login group. The group name must exist. A group
number must refer to an already existing group.
The default group number is 1.

-G group,[...]
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


Basically you have to specify all the groups you want them associated with when you use usermod or it doesn't know to keep the existing groups for the user, this is how you would remove them from groups, etc.
I quite frankly find it easier to just edit the /etc/group file.
 
Old 07-21-2004, 02:18 AM   #3
gjhicks
Member
 
Registered: Jun 2004
Location: Melbourne, Australia
Posts: 47

Original Poster
Rep: Reputation: 15
Hi,

Thanks for the reply.

I will also jusr edit the /etc/groups file.

It is a bit silly that usedmod doesn't have a switch to allow adding a group to a user.

Thanks again,

Geoff.
 
Old 06-18-2014, 02:31 AM   #4
Flymo
Member
 
Registered: Feb 2008
Location: Travelling, but less often now...
Distribution: Bodhi Linux, Puppy, Knoppix, Raspbian, Ubu Studio
Posts: 69

Rep: Reputation: 16
...belatedly, I know, but there is an answer to doing this with usermod

In order to add user 'fred' to admin, do this as root (or use sudo):

Code:
# usermod -a -G admin fred
Relevant, if not that timely!
 
  


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
add user to the group ashley75 Linux - General 4 03-30-2005 02:42 PM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:02 AM.

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
Open Source Consulting | Domain Registration