Linuxlab

Users and groups: useradd, usermod

Updated July 3, 2026

useradd creates a user, usermod changes one, groupadd creates a group. These commands need root.

sudo useradd -m alice        # create with a home directory (-m)
sudo usermod -aG devs alice  # add to the devs group without touching others
id alice                     # uid, gid, groups

How it works: why the -a in usermod -aG

usermod -G devs alice without -a REPLACES the supplementary group list with just devs and drops the user from every other group. -a means append - add to what is already there. This is a common, painful mistake, so almost always write -aG.

Used in

You need this in the lesson Users and permissions.