Home/Engineer/OS / Systems/Linux User and Group Managem…
OS / SystemsBeginnerubuntucentosdebianlinuxusergroup

Linux User and Group Management

Covers end-to-end server user administration, including creating and deleting users, managing groups, configuring sudo privileges, and applying password policies.

Contents
  1. User Management
  2. Group Management
  3. Account Expiration
  4. sudo Privileges
  5. Dedicated Service Accounts (Recommended for Security)
  6. Login Activity

User Management

Bash
sudo useradd -m -s /bin/bash deploy
sudo useradd -m -s /bin/bash -G docker,sudo deploy

sudo passwd deploy

sudo usermod -s /bin/zsh deploy
sudo usermod -aG docker deploy
sudo usermod -L deploy     # lock the account
sudo usermod -U deploy     # unlock the account

sudo userdel deploy
sudo userdel -r deploy     # also delete home directory and mail spool

Group Management

Bash
sudo groupadd devteam
sudo groupdel devteam

sudo gpasswd -a deploy devteam
sudo gpasswd -d deploy devteam

id
groups deploy
getent group docker

Account Expiration

Bash
sudo chage -l deploy
sudo chage -M 90 deploy           # force a password change every 90 days
sudo chage -E 2026-12-31 deploy   # account expiration date

sudo Privileges

Bash
sudo usermod -aG sudo deploy

# edit with visudo
deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginx, /usr/bin/docker *
%devteam ALL=(ALL) NOPASSWD: /usr/bin/docker

Bash
sudo useradd \
  --system \
  --no-create-home \
  --shell /sbin/nologin \
  --comment "App Service Account" \
  myapp

Login Activity

Bash
who
w
last
lastb    # failed login attempts
#linux#user#group#sudo#permission
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗NIST CSRC ↗

Questions & answers

Ask a question about this guide. We'll review and reply.