Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

sudoers

Direct answer

sudoers (/etc/sudoers and /etc/sudoers.d/) defines who may run which commands as which user with sudo, e.g. %admins ALL=(ALL) ALL.

When to use this

Use it to grant or limit administrative rights, or when sudo refuses a user.

First 30 seconds

1. sudo -l -U <user> — what may they run?

2. Not allowed → member of the admin group (sudo/wheel)? New login?

3. Add a rule with visudo -f /etc/sudoers.d/<name>.

4. Syntax check: visudo -c.

5. Test: sudo -u <user> sudo -l or log in as the user.

Operational verification

user runs sudo → rules matched (user/group, host, target user, command) → password if required → command runs and is logged

Evidence · next step

For Users & Groups → sudoers, continue with the first unproven Topic check: Identify invoking user/groups, host context, requested target identity and exact command path/arguments. If that boundary is healthy, advance to the adjacent check: Validate the effective sudoers policy including included files before applying changes. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to grant or limit administrative rights, or when sudo refuses a user.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

invoking process identity → sudo policy sources/includes → rule match → authentication/options/environment → target UID/GID transition → command execution → target/workload result

Healthy evidence: the minimum required rule matches only the intended invocation, resulting credentials are correct and the original administrative operation succeeds without broader privilege than needed.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Identify invoking user/groups, host context, requested target identity and exact command path/arguments.

  • Validate the effective sudoers policy including included files before applying changes.
  • Confirm the rule actually matched and capture the resulting effective UID/GID/environment.
  • Verify the target command and workload result separately under the delegated identity.

Verification chain. invoking process identity → sudo policy sources/includes → rule match → authentication/options/environment → target UID/GID transition → command execution → target/workload result

Step 3 Commands Verify boundary
visudo
visudo -c
sudo -l -U alice
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: sudo login/authentication is confused with policy authorization, wildcard rules overmatch, or root-command success is treated as evidence the normal service identity is fixed.

Step 5 Common mistakes Narrow the fault
  • Editing /etc/sudoers without visudo and breaking sudo.
Evidence references

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.

observation · 1
Key points

Always edit with visudo (or visudo -f /etc/sudoers.d/<file>) — a syntax error can lock everyone out of sudo. Prefer group rules over individual users. Avoid NOPASSWD for broad rules, and avoid allowing editors or shells that let users escape to root.

Key checks
  • visudo -c — syntax check of all sudoers files
  • id <user> — UID, primary group and groups
  • getent passwd <user> — account entry (local or directory)
  • getent group <group> — group members
  • sudo -l -U <user> — what the user may run with sudo
ReferenceWhat it is1 section · depth on demand

Core model

Trace the invoking identity, matched sudoers rule and effective target identity before evaluating the command itself. Consider include files, aliases, rule ordering/precedence semantics, command path/arguments where applicable and environment restrictions. A sudo policy match shows delegated authorization for the matched invocation, not that the target command is safe, correct or successful.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

A sudoers rule shows intended delegation only when it matches the exact invocation, but it does not show command safety, non-DAC policy, target state or workload success.

sudoers owns sudo authorization policy.

In depth

sudoers rules and safe administration

sudo lets users run commands as root, or as another user, according to rules in /etc/sudoers and its include directory. The sudoers manual describes rule syntax as "who where = (as_whom) what".

  • Groups are written with %.
  • Aliases (User_Alias, Runas_Alias, Host_Alias, Cmnd_Alias) group names and commands.
  • NOPASSWD: skips the password prompt for the commands that follow.
  • When several entries match, the last match wins, which isn't necessarily the most specific one.
  • @includedir /etc/sudoers.d reads all files there in sorted order, but skips files that end in ~ or contain a dot.

Rule examples

RuleMeaning
%sudo ALL=(ALL:ALL) ALLMembers of sudo may run anything, with their password
alice ALL=(root) /usr/bin/systemctl restart nginxOne specific command
%webops ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginxNo password for one command
deploy ALL=(appuser) NOPASSWD: /opt/app/bin/deployRun as appuser, not root
Cmnd_Alias LOGS = /usr/bin/journalctl, /usr/bin/tail -f /var/log/*An alias for reuse

Defaults worth knowing (manual)

DefaultBehaviour
env_resetOn: commands run with a minimal environment
secure_pathSets PATH for commands run through sudo
timestamp_timeout5 minutes of cached credentials
LoggingTo syslog by default

Pitfalls

PitfallWhy
Wildcards in argumentsThe manual warns they need care; tail -f /var/log/* also matches /var/log/../../etc/shadow
Allowing editors, shells, less or findThey can start a root shell; use sudoedit for file editing
A file in sudoers.d named app.confIgnored, because the name contains a dot
Editing without visudoA syntax error can lock everyone out of sudo
host$ sudo visudo -f /etc/sudoers.d/webops
%webops ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginx, /usr/bin/systemctl status nginx
host$ sudo visudo -c
/etc/sudoers: parsed OK
/etc/sudoers.d/webops: parsed OK
host$ sudo -l -U bob
host$ sudoedit /etc/nginx/sites-available/default
host$ sudo journalctl _COMM=sudo -n 3 --no-pager

sudoedit instead of sudo vi

sudoedit copies the file, opens it in the user's own editor without privileges, and writes it back as root. The editor never runs as root, so it can't be used to escape into a root shell.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

sudoers is part of Users & Groups → sudoers. sudoers is the policy model used by sudo to decide which invoking principals may run which commands as which target users/groups under defined host, authentication, environment and option constraints; policy authorization is distinct from the executed command result.

Topic-specific state model. sudoers is the policy model used by sudo to decide which invoking principals may run which commands as which target users/groups under defined host, authentication, environment and option constraints; policy authorization is distinct from the executed command result.

Interpretation rule. - sudo authentication success ≠ sudoers authorization.

  • sudoers authorization ≠ command/workload success.
  • Broad command path or wildcard policy ≠ least privilege.
  • Policy file edit ≠ syntax-valid/effective policy until parsed and matched in the real context.

Quick reference

sudoers grants commands to users and groups. Always edit with visudo (syntax check) and prefer drop-in files in /etc/sudoers.d/.

# /etc/sudoers.d/ops   (mode 0440)
%ops ALL=(ALL) ALL
Defaults:%ops timestamp_timeout=5
backup ALL=(root) NOPASSWD: /usr/bin/systemctl restart backup-agent, /usr/bin/rsync
Defaults logfile=/var/log/sudo.log, log_input, log_output
visudo -cf /etc/sudoers.d/ops
sudo -l -U alice
sudoreplay -l

Avoid allowing editors, shells, less, find, tar or interpreters via NOPASSWD — they can spawn root shells (see GTFOBins). Grant specific commands with fixed arguments.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. A sudoers rule shows intended delegation only when it matches the exact invocation, but it does not show command safety, non-DAC policy, target state or workload success.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Configuration intent and lifecycle. Treat /etc/passwd, /etc/shadow, /etc/group and sudoers as policy databases with strict syntax, ownership and permission requirements, while remembering that NSS can source identities elsewhere.

Distribution/platform context. sudoers owns sudo authorization policy. Users & Groups owns source identities; root/UID/GID owns resulting identities; application-specific privilege design remains elsewhere.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Users & Groups → sudoers. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.kernel.org/doc/man-pages/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
sudoers linuxsudo policyetc sudoerssudo authorization
Embedded reference data

Quick lookup tables

sudoers operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for sudoers.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statesudoers is the policy model used by sudo to decide which invoking principals may run which commands as which target users/groups under defined host, authentication, environment and option constraints; policy authorization is distinct from the executed command result.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin the exact process/session → resolve user/group names to numeric UID/GID through the effective identity stack → capture effective UID/GID + supplementary groups → resolve every required path component and target inode → inspect numeric owner/group + mode + ACL/mask + special bits → capture sudo/privilege transition if present → account for non-DAC controls → repeat the original workload operation.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chaininvoking process identity → sudo policy sources/includes → rule match → authentication/options/environment → target UID/GID transition → command execution → target/workload resultTrace requested/configured state through effective state to the observed workload result.
Failure boundaryA sudoers rule proves intended delegation only when it matches the exact invocation; it does not prove command safety, non-DAC policy, target state or workload success.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux identity and authorization evidence can establish this proof path: invoking process identity → sudo policy sources/includes → rule match → authentication/options/environment → target UID/GID transition → command execution → target/workload resultUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured identity source, process credential, filesystem object, DAC/ACL, privilege or workload scope. A sudoers rule proves intended delegation only when it matches the exact invocation; it does not prove command safety, non-DAC policy, target state or workload success.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: keep the same process/session, resolve numeric identity and groups, inspect each path component plus target ownership/mode/ACL/special bits, capture any privilege transition/non-DAC denial, then repeat the original operation before broadening permissions.Continue to the next unresolved boundary while preserving the original test condition.

sudoers · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundarysudoers
Topic pathUsers & Groups → sudoers
Runtime statesudoers is the policy model used by sudo to decide which invoking principals may run which commands as which target users/groups under defined host, authentication, environment and option constraints; policy authorization is distinct from the executed command result.
Fast checks- Identify invoking user/groups, host context, requested target identity and exact command path/arguments. - Validate the effective sudoers policy including included files before applying changes. - Confirm the rule actually matched and capture the resulting effective UID/GID/environment. - Verify the target command and workload result separately under the delegated identity.
Verification chaininvoking process identity → sudo policy sources/includes → rule match → authentication/options/environment → target UID/GID transition → command execution → target/workload result Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryA sudoers rule proves intended delegation only when it matches the exact invocation; it does not prove command safety, non-DAC policy, target state or workload success. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?