Use it when configuring, checking or troubleshooting sudo in Linux Security.
sudo
sudo delegates selected commands or roles under policy with invoking/target identities, host and argument constraints, authentication, environment handling, logging and session lifetime rather than granting unrestricted root by default.
1. sudo grants limited root actions.
2. Use groups and specific commands.
3. Avoid NOPASSWD and shell escapes (vim, less).
4. Log via syslog/sudo I/O logs.
5. Edit with visudo.
user → sudoers rule → command as root → logged
Context & applicabilityCommon mistakes · platform/version boundaries
A sudo policy match shows delegated execution under specified conditions, but it does not show the command cannot escape or the human action was authorized in context.
Suspicious evidence: ALL grant, wildcard arguments, writable command path, editor/shell escape, preserved dangerous environment, included file shadowing, long timestamp or logs incomplete.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
invoking identity/host → sudo policy parse/order → authentication/session → command/path/args/environment match → target credentials → execution/log → resource outcome
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- sudo access ≠ root shell intentionally or safely permitted.
- Command path restricted ≠ arguments, environment, editors or child processes non-escapable.
- Configuration file present ≠ parsed, loaded and effective runtime state.
- One allow/deny result ≠ complete DAC, privilege, LSM, firewall and application outcome.
sudo -l -U <user>— rightsvisudo -c— syntax checkgrep -r NOPASSWD /etc/sudoers /etc/sudoers.d/— passwordless rules
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A sudo policy match shows delegated execution under specified conditions, but it does not show the command cannot escape or the human action was authorized in context.
In depth
sudo lets permitted users run specific commands as root or another user, with every use logged. It replaces shared root passwords with individual accountability and allows fine-grained privilege.
# /etc/sudoers.d/netops (edit with visudo -f)
%netops ALL=(root) /usr/bin/systemctl restart nginx, /usr/bin/journalctl -u nginx
Defaults:%netops log_output, timestamp_timeout=5
Pitfalls:
| Risky rule | Why |
|---|---|
ALL=(ALL) NOPASSWD: ALL | Full root without re-authentication |
Allowing editors, pagers, interpreters (vi, less, python) | Can spawn shells |
| Wildcards in arguments | Can be abused to run other commands |
| Scripts writable by the user | User can change what runs as root |
sudo -l # what may I run?
Send sudo logs centrally; consider sudo_logsrvd or session recording for privileged access.
ReferenceConfiguration & state1 section · depth on demand
Configuration
# /etc/sudoers.d/netops (edit with visudo -f)
%netops ALL=(root) /usr/bin/systemctl restart nginx, /usr/sbin/nft list ruleset
Defaults logfile=/var/log/sudo.log
Defaults use_pty
Documented example, not captured output. Avoid NOPASSWD: ALL and commands that allow shell escapes (vi, less, find -exec, tar). sudo -l shows what a user may run. sudo versions before 1.9.5p2 had a critical heap overflow (Baron Samedit); keep it patched.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Security → sudo. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/security/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Linux Security → sudo proof map
Fast scope, effective-state, runtime-evidence and closure boundaries for Linux Security → sudo.
| Boundary | Establish | Does not establish |
|---|---|---|
| Scope | Exact host, role, build/kernel, identity, workload and expected control | Does not prove policy receipt or effective runtime state |
| Effective state | Resultant/loaded policy, precedence, mode, labels/rules/keys and active services/kernel controls | Configuration presence does not prove enforcement |
| Runtime evidence | Correlated events/audit, process/token/credential, packet/syscall and workload result | One event, clean status or allow/deny does not prove complete security |
| Closure | Original allowed/denied workload works, unsafe state is removed and recovery/regression pass | Commit, restart, block or compliance result alone is not closure |