usermod

Change a user, for example add them to a group

What it does

usermod changes the settings of an existing user. Most often, their supplementary groups: -aG docker anna adds anna to the docker group so she can run containers without sudo.

New groups take effect from the next login: the user has to log in again or reconnect over SSH. groups <user> shows which groups a user is in.

Careful. Without -a, -G does not add but replaces the list of groups: the user drops out of all the others, sudo included. Always type -aG together.

Syntax

sudo usermod -aG <group> <user>
groups <user>

Examples

Related commands

Practise · All commands