[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vim -- adduser vs useradd/usermod



Hi,

On Fri, Nov 23, 2012 at 07:56:24AM -0600, Nate Bargmann wrote:
> * On 2012 23 Nov 06:14 -0600, Andrei POPESCU wrote:
> > On Vi, 16 nov 12, 16:33:17, Nate Bargmann wrote:
> > > * On 2012 16 Nov 14:02 -0600, james gray wrote:
> > > > i am using vim to add the one and only name in a usr account to the groups
> > > > file for printing.
> > > 
> > > I would use, as super user:
> > > 
> > > # usermod -Ga lp <username>
> > 
> > On Debian the 'adduser' tool should be used.

Maybe this is a bit strong statement.  I would just say the use of
adduser on Debian system makes life easy on Debian.
 
> Unfortunately, the name alone doesn't lend itself to knowing that it
> will modify a user account although the man page says:
> 
>    Add an existing user to an existing group
>           If called with two non-option arguments, adduser will add  an
> 	  existing user to an existing group.
> 
> The page is silent as to whether existing group membership is preserved
> as with the command example I offered.  To know it would be required for
> each adminstrator to test this command due to this documentation bug.

I think there is a reason why adduser is not called changeuser (or
updateuser) (just joking though). I am very certain this only "ADD"
things.  If it REMOVES something, this is a serious documentation bug
not to mention it.  But it just works as expected...  I think.

> In this case, 'usermod' provides the adminstrator *exactly* the options

Although adduser for this is the popular utility to use here and the one I
probably use, usermod seems to be as legitimate utility and it comes as a part
of shadow-utils i.e. the passwd package.

Both should work.  Otherwise, file a bug report :-)

> needed to modify a user account.  A single or multiple groups may be
> easily added, or the group list may be passed in such a way as to easily
> remove an account from several groups at once while preserving or adding
> membership in those passed.

If adduser should do such things, there should be a lot of unhappy people
filing bug report ...

> I don't see that capability in 'adduser'
> although there is the complementary 'deluser' which removes a sepcific
> user from a specific group.  To remove an account from multiple groups
> would require multiple invocations.
> 
> Power or simplicity?  The choice is yours.

Power -- certainly.  If you read /usr/share/doc/adduser/examples/README,
there are good power tools described.

For not so much involved like me, adduser is a friendlier interactive
frontend to useradd. At least, this is my impression and that is why I
used it for Debian Reference.

I google and find interesting old post here.

> Subject: Re: adduser, useradd: are there any differences
> From: "Peter J. Holzer" <hjp-debian@hjp.at>
> Date: Sun, 12 Sep 2004 20:55:39 +0200
> On 2004-09-12 18:12:02 +0200, Roland Wegmann wrote:
...
> useradd and groupadd are the posix or SUS-standardized tools to create
> users and groups. You can expect them to work (almost) identically on all Linux
> distributions as well as on HP-UX, Solaris, AIX, ...
> 
> adduser and groupadd are distribution specific wrappers which make it
> simpler to create users which conform to some (distribution-specific or
> local) policy. The options vary wildly between different distributions
> and other UNIXes may not have these commands at all.

(As I checked web, FEDORA/CENTOS/GENTOO, adduser seems to be the symlink
to useradd.)

Osamu


Reply to: