Permissions, users and access

Command usermod

Change user settings

Linux · Bash examples · commands run on the selected server

When to use usermod

Use usermod to change an existing account's configuration. Group changes and shell changes can affect access and running workflows; preserve existing memberships unless replacing them is the explicit goal.

Syntax

usermod [PARAMETERS] NAME

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-aG GROUPS
Add additional groups while keeping the existing ones.
-s SHELL
Change login shell.
-L
Lock user password.

Usage examples

Add user to group

sudo usermod -aG developers demo-user

The account is appended to a supplementary group while retaining its other memberships.

Change shell

sudo usermod -s /bin/bash demo-user

The configured login shell is changed for future logins.

Check groups after change

id demo-user

The account's configured groups are inspected after the change.

Notes and limitations

  • The -G key without -a replaces the list of additional groups.
  • Group changes usually take effect for the user after a new login.

Common questions and troubleshooting

Why did other supplementary groups disappear?

Setting a group list without append mode replaces it. Restore the intended memberships from a trusted record and use append mode for additions.

Why does the current session still have old groups?

A running session usually retains the groups assigned at login. Reconnect and inspect the active group set after changing membership.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man usermod.