Where to start First steps track · 15 stages
Linux Labs

usermod — change an account and its groups

cheat sheet · Ubuntu 24.04 · shadow 4.13 https://lab.dimsanych.ru/en/wiki/usermod/

Cheat sheet

  • sudo usermod -aG adm alice add a user to a group, keep others
  • sudo usermod -rG adm alice remove from a group (or gpasswd -d)
  • sudo usermod -G adm,www-data alice set the whole group list anew
  • sudo usermod -g devs alice change the primary group
  • sudo usermod -s /bin/bash alice login shell
  • sudo usermod -s /usr/sbin/nologin svc forbid login
  • sudo usermod -L alice lock the password; -U unlocks
  • sudo usermod -e 2026-12-31 alice the date the account expires
  • sudo usermod -d /home/al -m alice move the home directory
  • id alice check the result

Options

Full list — man usermod. gpasswd options: -a add, -d remove, -M set the group's member list.

Loading…