System

User Management

User management commands for Linux system administration.

34 commands
Windows MacOS Linux
#user-management #linux

User Creation

Create a new user
useradd alice
Create user with home directory
useradd -m alice
Create user with shell and home
useradd -m -s /bin/bash alice
Create user with supplementary groups
useradd -m -G sudo,docker alice
Create a system service account
useradd -r -s /usr/sbin/nologin svc
Create user with expiry date
useradd -e 2026-12-31 contractor

User Modification

Add user to a group
usermod -aG docker alice
Change user shell
usermod -s /bin/zsh alice
Change home directory
usermod -d /home/newhome alice
Rename a user account
usermod -l newname oldname
Lock a user account
usermod -L alice
Unlock a user account
usermod -U alice
Delete user and home directory
userdel -r alice

Group Management

Create a new group
groupadd developers
Rename a group
groupmod -n devs developers
Delete a group
groupdel developers
Add user to group
gpasswd -a alice developers
Remove user from group
gpasswd -d alice developers
Switch primary group in session
newgrp docker

Password Management

Set or change user password
passwd alice
Lock user password
passwd -l alice
Unlock user password
passwd -u alice
Show password aging info
chage -l alice
Set max password age to 90 days
chage -M 90 alice
Set account expiration date
chage -E 2026-12-31 alice

Info & Listing

Show user UID, GID, and groups
id alice
Show current username
whoami
Query user from name service
getent passwd alice
Query group membership
getent group docker
Show logged-in users and activity
w
Show recent login history
last

Quick Commands

Create a new user with home directory and shell
useradd -m -s /bin/bash alice
Add a user to a supplementary group
usermod -aG docker alice
Show user UID, GID, and groups
id alice