How do I add an existing user to a group?

This is a discussion on How do I add an existing user to a group? within the Linux Security forums, part of the System Security and Security Related category; When I added the user with useradd, I put him in a single group with the -g option. Now, I ...


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-22-2005
MLH
 
Posts: n/a
Default How do I add an existing user to a group?

When I added the user with useradd, I put him in a single group with
the -g option. Now, I want to add the user to several more groups.
What linux command is used to do this? And, can I add user to more
than a single group in a single instance of the command?

Thx - am new at this - fully appreciate all assistance.
Reply With Quote
  #2 (permalink)  
Old 03-22-2005
Shane (aka froggy)
 
Posts: n/a
Default Re: How do I add an existing user to a group?

On Mon, 21 Mar 2005 22:24:50 -0500, MLH wrote:

> When I added the user with useradd, I put him in a single group with
> the -g option. Now, I want to add the user to several more groups.
> What linux command is used to do this? And, can I add user to more
> than a single group in a single instance of the command?
>
> Thx - am new at this - fully appreciate all assistance.


to modify an existing users groups (to add them to more groups )
usermod -G <new group>

to do this during the creation of an account
useradd -G <extra group>

HTH
--

Hardware, n.: The parts of a computer system that can be kicked

Reply With Quote
  #3 (permalink)  
Old 03-22-2005
MLH
 
Posts: n/a
Default Re: How do I add an existing user to a group?

Many thx.
xxxxxxxxxxxxxxxxxxxxxxxx


<snip>
>to modify an existing users groups (to add them to more groups )
>usermod -G <new group>
>
>to do this during the creation of an account
>useradd -G <extra group>
>
>HTH


Reply With Quote
  #4 (permalink)  
Old 03-23-2005
Lew Pitcher
 
Posts: n/a
Default Re: How do I add an existing user to a group?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Shane (aka froggy) wrote:
> On Mon, 21 Mar 2005 22:24:50 -0500, MLH wrote:
>
>
>>When I added the user with useradd, I put him in a single group with
>>the -g option. Now, I want to add the user to several more groups.
>>What linux command is used to do this? And, can I add user to more
>>than a single group in a single instance of the command?
>>
>>Thx - am new at this - fully appreciate all assistance.

>
>
> to modify an existing users groups (to add them to more groups )
> usermod -G <new group>


Caveat: the argument -G takes a list of groups, and uses that list to
/replace/ the supplemental group list that your user currently has. If you
just -G the new group, the user will lose membership in all other supplemental
groups. See the usermod(8) manpage for details - look for the -G description
that reads

-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
=================*******===============


> to do this during the creation of an account
> useradd -G <extra group>


Similarly, the useradd(8) -G option lists /all/ the supplemental groups that
the user belongs to. Miss one, and you will have to usermod(8) the user to add
the group in later.

- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFCQOqKagVFX4UWr64RAnh0AJ98ADbgtC9XBzL4N6NO7C 2YVAXpDACg52LF
MXQhwP5RlnV0rP+wzNYB8p0=
=BDUo
-----END PGP SIGNATURE-----
Reply With Quote
  #5 (permalink)  
Old 03-23-2005
Wayne
 
Posts: n/a
Default Re: How do I add an existing user to a group?

MLH wrote:
> When I added the user with useradd, I put him in a single group with
> the -g option. Now, I want to add the user to several more groups.
> What linux command is used to do this? And, can I add user to more
> than a single group in a single instance of the command?
>
> Thx - am new at this - fully appreciate all assistance.


The easy way is to use the gpasswd command. See the man page.

-Wayne
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:50 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0