Skip to content

usermod command

Change user accounts: groups, shell, home, lock.

On this page

Syntax

usermod [options] username

Provided by the passwd / shadow-utils package. Run man usermod for the full manual.

Common options

OptionWhat it does
-aG GROUPSAdd to extra groups (keep the others)
-G GROUPSSet the extra groups (removes others)
-s SHELLChange the login shell
-l NEWRename the user
-L / -ULock / unlock the password
-d DIR -mMove the home directory

Examples

  1. Add a user to sudo (Ubuntu)

    sudo usermod -aG sudo alice
  2. Add a user to docker

    sudo usermod -aG docker $USER
  3. Change the shell

    sudo usermod -s /bin/zsh alice
  4. Lock an account

    sudo usermod -L alice
  5. Rename a user

    sudo usermod -l alicia alice
  6. Remove from a group

    sudo gpasswd -d alice docker

Tips

  • Always use -aG; -G alone replaces all extra groups.
  • Group changes apply at the next login (or run newgrp docker).

usermod guides

← All Linux commands · Suggest a fix

Back to top