What is the difference between

adduser user_name group_name 


usermod -G -a user_name group_name 

At first glance they seems to do the same thing : add a user to a group.

  • usermod -G -a user_name group_name would be wrong either way. I think you'd want usermod -G group_name -a user_name or usermod -a -G group_name user_name instead.
    – Mismatch
    Apr 24, 2023 at 14:21

2 Answers 2


adduser and usermod are two different utilities which have in common the fact that both can add a user to a group.

According to man adduser

adduser is friendlier front ends to the low level tools like useradd, groupadd and usermod programs.

More info:

  • man adduser : adduser, addgroup - add a user or group to the system
  • man usermod : usermod - modify a user account
  • ok so, the two commands I give do exactly the same thing ?
    – snoob dogg
    Mar 4, 2018 at 15:12
  • @snoobdogg What is meant is that they are different. usermod cannot add a user to the system like adduser can. They just happen to share the ability to add a user to a group.
    – Terrance
    Mar 4, 2018 at 15:14
  • ok I get it, but the two commands I give in my question do the same thing yes or no?
    – snoob dogg
    Mar 4, 2018 at 15:17
  • @snoobdogg - you can add a user to a group using the two commands as you specify in your question. Those two commands differ in various other parameters.
    – Yaron
    Mar 4, 2018 at 15:19
  • 1
    @snoobdogg Yes, they are the same commands. From the adduser man page: If called with two non-option arguments, adduser will add an existing user to an existing group.
    – Terrance
    Mar 4, 2018 at 15:20

At first glance, yes.

At second glance, usermod -G -a user_name group_name is not correct.

The -G option should be followed by the group name(s).

$ sudo usermod -G -a nogroup muru
[sudo] password for muru:
usermod: group '-a' does not exist
$ sudo usermod -a -G muru nogroup
usermod: user 'nogroup' does not exist

The -a can come before -G, or after the group name(s), but not between -G and the group name(s).

As a side note, adduser itself uses gpasswd:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .