Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The command I use is:

sudo useradd -g users tom

It should add tom to the group users, but I can't find tom in users when checking /etc/group.

However, if I just try:

sudo useradd -G users jim

I find that jim is added to users successfully.

Anyone has ever come across this problem?

share|improve this question
up vote 3 down vote accepted

Note: useradd is a low-level utility and it is highly recommended you use adduser (or usermod) instead on Ubuntu/Debian systems

  • You are better off using the id -Gn username command to check primary/secondary membership rather than relying on /etc/group
  • The -g option to useradd sets the primary (or login) group of a new user

    • If set to an existing group, this will not be reflected in /etc/group
    • But you can see the existing GID in /etc/passwd or using id -Gn username
    • Example (group izx is gid 1000):
      $ sudo useradd -g izx tom
      $ grep ^izx /etc/group
      $ grep ^tom /etc/passwd
      $ id -Gn tom
  • The -G option to useradd sets the secondary (or supplementary) group(s) of a new user

    • These memberships will be reflected in /etc/group and using id -Gn username
    • But not in /etc/passwd (compare to -g above)
    • Example (group izx is gid 1000):
      $ sudo useradd -G izx harry
      $ grep ^izx /etc/group
      $ grep ^harry /etc/passwd
      $ id -Gn harry
      harry izx
share|improve this answer
Thank you for the answer! – xczzhh Jul 24 '12 at 17:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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