Intermediate Package: shadow-utils / passwd

usermod

Modify an existing user account.

Syntax

usermod [options] username

Description

usermod changes attributes of an existing account, such as its groups, home directory, shell or lock status, without needing to recreate the user.

Examples

sudo usermod -aG docker alice
Add a user to an additional group (-a appends, avoid omitting it)
sudo usermod -s /usr/bin/zsh alice
Change a user's default shell
sudo usermod -L alice
Lock an account, preventing password login
Always use -aG (append), not -G alone, or the user will be removed from all other groups.

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux