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.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
usermod are two different utilities which have in common the fact that both can add a user to a group.
According to man adduser
adduseris friendlier front ends to the low level tools like
At first glance, yes.
At second glance,
usermod -G -a user_name group_name is not correct.
-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
-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
$ grep gpasswd $(which adduser) my $gpasswd = &which('gpasswd'); &systemcall($gpasswd, '-a',$existing_user,$existing_group);