SSH, Security & Permissions

sudo rejects an account or command

Correct authentication does not grant a command absent from sudo policy. Compare current group membership and the exact allowed command.

On this page
  1. Symptoms & scope
  2. Possible causes
  3. Diagnose safely
  4. Evidence-guided next steps
  5. References & review
  6. Related problems

Symptoms & scope

  • sudo reports that the user or command is not authorized.
  • A newly added admin group has no effect in an existing session.

Relevant environment

sudo with sudoers policy; listing rules may request authentication but does not execute the proposed privileged command.

Recognizable messages (synthetic examples)
sudo: example : user NOT in sudoers ; TTY=pts/2 ; PWD=/home/example ; USER=root ; COMMAND=/usr/bin/id

Check policy and group membership; changing the user password does not supply a missing authorization.

sudo: example : command not allowed ; TTY=pts/2 ; USER=root ; COMMAND=/usr/bin/systemctl restart example.service

Inspect command path, arguments and RunAs target rather than widening all account privileges.

Possible causes

These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.

  • The current process may not have the account’s new supplementary groups.
  • The rule may constrain command paths, arguments, target users or hosts.

Diagnose safely

Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.

Check 1

Prints identity and groups of the current shell without querying or changing sudo policy.

id

Interpret the result: Compare with the intended authorized group; group membership in an account database does not update already running shells.

Check 2

Lists permitted commands for the current account. It may ask for authentication and write normal audit records; it does not run a listed command.

sudo -l

Interpret the result: Read RunAs targets, full paths and argument restrictions. An authentication failure here does not prove a missing sudoers rule.

Evidence-guided next steps

Refresh a legitimately changed group session

If an administrator already added the account to the intended policy group, save work and log out fully, then log in again. Check id and sudo -l in the new session before retrying the exact permitted operation.

Precautions: Distribution group names differ. Joining an administrative group is a privilege grant, not a generic permission repair.

Recovery / rollback: To revoke the grant, the administrator removes that membership and ends affected sessions; logging back in alone does not revoke it.

Did this solution help you?

Share this solution#

Have an administrator repair the narrow rule

If a required operation is absent, an existing administrator should edit the appropriate sudoers fragment with visudo and specify the required target user, full command path and safe arguments. Validate the complete policy and retain recovery access.

Precautions: Do not grant ALL or NOPASSWD: ALL as a shortcut. User-writable executables and broad argument wildcards can defeat restrictions.

Recovery / rollback: Remove the added rule through visudo or restore the saved fragment, then validate the complete policy again.

Did this solution help you?

Share this solution#

References & review

This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.