Users

The usermod command

Modifies a user account: groups, shell, home directory, account lock, and more.

Syntax

sudo usermod [-aG grupos] usuario

Most useful options

-aGAdds to groups without removing current ones
-sChanges the shell
-LLocks the account
-UUnlocks the account

Copy-ready examples

$ sudo groupadd equipo && sudo usermod -aG equipo alumno && groups alumnoAdd to a group

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • Without -a, -G replaces all secondary groups: always use -aG.

Related commands

FAQ

Why do I not see the new group in my session?

Groups apply at login; log back in or use newgrp.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course