Chapter 6

Users & Groups

Linux is multi-user: each person has an account, and users can belong to groups for shared access to files and resources.

User accounts

Each user has a username, home directory (usually /home/username), and a default shell. The root user (UID 0) has full system access.

Useful commands

CommandDescription
whoamiPrint current username
idShow user and group IDs
sudoRun a command as root (if allowed)
su - userSwitch to another user (login shell)
useradd / adduserCreate a new user
usermodModify user (e.g. add to group)
groupaddCreate a new group

Adding a user (example)

Terminal
sudo adduser alice
sudo usermod -aG sudo alice   # allow alice to use sudo

Avoid logging in as root for daily use. Use a normal user and sudo when you need administrative privileges.