I have an user john and an user keith in Ubuntu server

I added these users using

sudo adduser John 
sudo adduser Keith

How can I now add john to Keith's group?

I tried:

sudo usermod -aG Keith john

But I get:

usermod: group 'Keith' does not exist

What do I need to do to resolve this issue?

3 Answers 3


You can use: usermod -a -G grouptoadd username

Since it is far less obvious than I thought why -a -G is ok while -aG is not I'll try to explain it:

The -G options takes either one value or a list of values. In case of one value the value may be given like: -GVALUE since there is no requirement to have a space between the option and the value. This is just common practice.

If you have a group called a on your system, then calling -Ga becomes ambiguous. Do you want the user to have only one group a? Are you calling -a and -G? Then is "a" a value to -G? Where is the rest of the value (to -G)? It is also common practice that any single-letter option can before any other single letter option. so tat -xy == -yz. But this is ambiguous when one of the options can take either a single value like VALUE or many values like VAL1,Val2,val4,etc.

So in order to make the command FAILSAFE and work properly for all input you have to separate -a from -G

From man usermod:


usermod - modify a user account


usermod [options] LOGIN


The usermod command modifies the system account files to reflect the changes that are specified on the command line.


The options which apply to the usermod command are:

  • -a, --append

    Add the user to the supplementary group(s). Use only with the -G option.

  • ...

  • -G, --groups GROUP1[,GROUP2,...[,GROUPN]]]

    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. This behaviour can be changed via the -a option, which appends the user to the current supplementary group list.

  • ...

  • Might help to explain why splitting the options would work, and what options they are.
    – Journeyman Geek
    Oct 13, 2012 at 14:35
  • @JourneymanGeek: Done! runs... Oct 13, 2012 at 14:39
  • superusers should know how to man, imho... Oct 13, 2012 at 14:40
  • @ЯрославРахматуллин, superusers should indeed. However, most questions are asked by "non-superusers" and answered by "superusers". Someone who is new to linux has no reason to know of the man command. In any case, the command you gave is the same as the one executed by the OP, your answer does not explain why it did not work for her. On my system at least, splitting the options makes no difference. Oct 13, 2012 at 14:51
  • Well, first of all you can't run sudo adduser name sudo adduser name2 because that is invalid syntax for useradd. useradd takes one username argument. To add two users you have to run the command twice. IE useradd arne; useradd kari. Then you can add kari to arnes group and vice versa. Ill grow some more patience after watching a few more of these questions and answer properly. promise! Oct 13, 2012 at 14:59

If you executed the commands exactly as you have shown in your question, you did not create the user Keith, but only the user John. To execute commands one after the other on the command line you need to separate them using ; or &&. Otherwise, only the first command will be run:

sudo adduser John sudo adduser Keith
adduser: Only one or two names allowed.

If you did execute them correctly, be careful about capital letters. In your question you mention both "John" and "john". This should work:

sudo adduser keith
sudo adduser john
sudo usermod -aG keith john

You can also edit the configuration files manually:

sudo nano /etc/password
sudo nano /etc/group

Assign the ID and other fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.