Sudo and privilege boundaries
Use elevated privileges as a scoped action, not a working mode.
sudo -l
20 min read, 25 min lab
foundation
`sudo` runs a command with elevated privileges according to policy. It should be used for the specific operation that needs privilege, after read-only checks have narrowed the target.
You need to restart a service, but first you should prove service state and permissions.
Worked command
$ sudo -l$ systemctl status nginx.service$ sudo systemctl restart nginx.service
Do not switch into a root shell because one command failed.
Perform read-only checks first, then run one scoped privileged command if needed.
A service looks broken and you have sudo. What is the operator-correct first move before any privileged change?
Show the answer
Correct: A. Run read-only checks (sudo -l, systemctl status) to confirm policy and state first
Read-only checks narrow the target and prove what is actually wrong before you spend a privileged action. A root shell turns a scoped privilege into a working mode, where one wrong command runs unguarded across the system.
Practice checklist
- Read `sudo -l` on a lab machine if available.
- Write a privileged action plan without executing it.
- Name the read-only checks that come first.
Deliverable evidence
- A sudo action plan that separates read-only checks from privileged action.
shows: How a file's access splits into ownership (who) and mode bits (what) per user/group/other class, how umask seeds defaults, and where sudo crosses the boundary.
does not prove: It shows the model, not your case: only running ls -l, stat, id, and sudo -l on the actual file proves who you are and what access you currently hold.
Commit these to memory, then drill them until recall is automatic.
cue Before using sudo to restart or modify a service, what comes first?
show recall target
read-only checks: sudo -l, then systemctl status <unit>