Fix "user is not in the sudoers file. This incident will be reported."
user is not in the sudoers file. This incident will be reported.
- alice is not in the sudoers file. This incident will be reported.
- alice is not in the sudoers file.
- alice is not allowed to run sudo on myhost. This incident will be reported.
- Sorry, user alice is not allowed to execute '/usr/bin/apt update' as root on myhost.
- Sorry, user alice may not run sudo on myhost.
Your account is not allowed to use sudo: it is neither in the admin group (sudo on Debian and Ubuntu, wheel on Fedora, RHEL and Arch) nor in a rule in /etc/sudoers. Log in as root, add the user to the group with usermod -aG, then log out and back in.
What this error means
sudo reads /etc/sudoers and the files in /etc/sudoers.d/ to know who may run what. Distributions grant a whole group there: %sudo on Debian and Ubuntu, %wheel on Fedora, RHEL and Arch, %admin on macOS. If your user matches no rule, sudo refuses and writes the attempt to the system log: that is what "This incident will be reported" means. Recent sudo versions no longer print that second sentence. A plain sudo command cannot fix this: you must act from an account that already has root rights.
Common causes
- Debian installed with a root password: if you set a root password during installation, the first user is not added to the
sudogroup. - New user created without an admin group:
adduseroruseradddo not grantsudorights by default. - Group added but session not reopened: groups are read at login, so the change is not visible in the current session.
- Wrong group for the distribution:
sudoinstead ofwheelon Fedora or Arch. On Arch, the%wheelline in sudoers is even commented out by default.
Step-by-step fix
-
Get a root shell
With the root password, use
su -. On Ubuntu, the root account is locked: use another admin account, or recovery mode (GRUB menu > Advanced options > recovery mode > root), then make the disk writable. Under WSL, open PowerShell and runwsl -u root.# With the root password (Debian, Fedora...) su - # Ubuntu recovery mode: remount the root file system read-write mount -o remount,rw / # WSL (from PowerShell) wsl -u root -
Add the user to the admin group
From the root shell, add your user to the right group. The
-aoption is essential: without it,-Greplaces all of the user's secondary groups.# Debian, Ubuntu, Linux Mint usermod -aG sudo alice # Fedora, RHEL, Rocky, AlmaLinux, Arch usermod -aG wheel alice -
Check the group rule with visudo
On Arch in particular, uncomment the
%wheelline in sudoers. Always edit this file withvisudo: it checks the syntax before saving, whereas an error in a hand-edited/etc/sudoerslockssudofor everyone.EDITOR=nano visudo # uncomment this line: # %wheel ALL=(ALL:ALL) ALL # Check the whole configuration visudo -c -
Or create a dedicated rule
To grant rights to a single user without touching the main file, create a file in
/etc/sudoers.d/, always throughvisudo -f. AvoidNOPASSWD: ALL: any program running under that account could then become root without a password.visudo -f /etc/sudoers.d/alice # content: alice ALL=(ALL:ALL) ALL -
Reopen the session and test
Log out completely (or close the SSH session) then log back in. Then check that the group shows up and that
sudoworks.groups sudo -v sudo -l -
macOS: make the account an administrator
On a Mac,
sudois reserved for administrators. From an admin account, open System Settings > Users & Groups, click the account and turn on "Allow this user to administer this computer", or usedseditgroup.sudo dseditgroup -o edit -a alice -t user admin
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Add your user to the admin group right after installing a server, before disabling root login over SSH.
- When editing sudoers, keep a root shell open and test
sudo -vin a second terminal before closing it. - Never use a regular editor on
/etc/sudoers: always go throughvisudo.
Frequently asked questions
"This incident will be reported": to whom?
The attempt is recorded in the system logs (journalctl or /var/log/auth.log), and an email may be sent to root if a local mail server is set up. Nobody else is notified.
I do not have the root password on Ubuntu, what can I do?
Use another admin account if there is one. Otherwise, boot into recovery mode from GRUB, choose "root", run mount -o remount,rw /, then usermod -aG sudo your_user.
Do I need to reboot after usermod?
No, logging out and back in is enough. For an SSH session, disconnect and reconnect.
Useful tools for this error
More Systems (Windows, macOS, Linux) errors
- Fix "command not found" and "is not recognized as an internal or external command"
- Fix "running scripts is disabled on this system" in PowerShell
- Fix "xcrun: error: invalid active developer path" on macOS
- Fix "SSL certificate problem: unable to get local issuer certificate" (git, curl, pip, npm)
- Fix "/bin/bash^M: bad interpreter: No such file or directory"
- Fix "E: Could not get lock /var/lib/dpkg/lock-frontend" (apt, Ubuntu, Debian)
- Fix "App is damaged and can't be opened" on macOS (Gatekeeper)