cmdxray / commands / usermod

What does usermod do?

modify an existing user account.

▸ Explain your own usermod command →

usermod examples, explained

$ usermod -aG docker alice

  • usermodmodify an existing user account
  • -aappend to groups instead of replacing (use with -G)
  • -Gset supplementary groups (replaces the list unless -a)
  • dockervalue for -G
  • alicean argument passed to the command

$ usermod -s /bin/zsh bob

  • usermodmodify an existing user account
  • -schange the login shell
  • /bin/zshvalue for -s
  • boban argument passed to the command

$ usermod -L olduser

  • usermodmodify an existing user account
  • -Llock the account's password
  • olduseran argument passed to the command

usermod flags & options

-lchange the login name
-Gset supplementary groups (replaces the list unless -a)
-aappend to groups instead of replacing (use with -G)
-schange the login shell
-dchange the home directory path
-mmove the contents of the old home to the new one (with -d)
-Llock the account's password
-Uunlock the account's password
-uchange the numeric user ID
-gchange the primary group
-cchange the comment / full-name field
-echange the account expiration date
--appendappend to groups instead of replacing (use with -G)
--groupsset supplementary groups
--loginchange the login name
--shellchange the login shell
--homechange the home directory path

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.