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
| Command | Description |
|---|---|
whoami | Print current username |
id | Show user and group IDs |
sudo | Run a command as root (if allowed) |
su - user | Switch to another user (login shell) |
useradd / adduser | Create a new user |
usermod | Modify user (e.g. add to group) |
groupadd | Create 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.