Difference between adding sudo user with adduser or gpasswd

6,517

Ultimately, Debian's (and therefore Ubuntu's) adduser calls gpasswd:

my $gpasswd = &which('gpasswd');                           
&systemcall($gpasswd, '-a',$existing_user,$existing_group);

Debian's adduser was written with the purpose of being a convenient frontend to a range of utilities (it makes use of, at one step or another, useradd, gpasswd, usermod, passwd, chfn, and a couple more commands). adduser and co. are somewhat distro-specific in nature, being frontend scripts. The one you see is from Debian, while Slackware and FreeBSD (at least) have their own.

I'd expect a consistent interface with the lower level commands like usermod and gpasswd, since they seem to originate from a common set of tools according to the origins of the package in Debian (and thereby Ubuntu, Arch Linux, Fedora, and CentOS), and Slackware.

On the other hand, Debian recommends that system administrators use adduser, etc.

Share:
6,517

Related videos on Youtube

RationalDev likes GoFundMonica
Author by

RationalDev likes GoFundMonica

Updated on September 18, 2022

Comments

  • RationalDev likes GoFundMonica
    RationalDev likes GoFundMonica over 1 year

    To add a new sudo user I believe I can call:

    # to create a new user
    sudo adduser newusername
    

    and to allow this user to use sudo I can do:

    sudo adduser newusername sudo
    

    or

    sudo gpasswd -a newusername sudo
    

    If this is correct, is there any difference between these commands or reasons to use one over the other for primarily Ubuntu server hardening script, but also trying to be as generic as possible, eg different Linux versions or distribution compatibility?

  • RationalDev likes GoFundMonica
    RationalDev likes GoFundMonica about 9 years
    This also gave me the idea to open commands in an editor and check the Perl script to see how it works.
  • Mr-Programs
    Mr-Programs over 5 years
    so... you recommend gpasswd? I wonder why debian recommends adduser