Managing Users & Groups
Creating & Modifying Accounts
| Command | Purpose |
|---|
useradd -m -s /bin/bash alice | Create user with home + shell |
passwd alice | Set/change password |
usermod -aG sudo alice | Append to a supplementary group |
usermod -L / -U | Lock / unlock account |
userdel -r alice | Delete user and home |
groupadd devs | Create group |
groupdel devs | Delete group |
id alice | Show UID/GID/groups |
chage -l alice | Password ageing info |
$ useradd -m -s /bin/bash alice && id alice
uid=1001(alice) gid=1001(alice) groups=1001(alice)
Exam trap: Always use usermod -aG (append). Plain usermod -G replaces all supplementary groups and will silently remove the user from others.