Fix "User Is Not in the sudoers File" and Create a sudo User (Ubuntu, Debian, RHEL)
"user is not in the sudoers file. This incident has been reported" means the account has no sudo rights. Add it to the sudo or wheel group, or give it a sudoers.d rule, then log in again. Tested on Ubuntu 24.04 with sudo and sudo-rs.
Originally published in March 2015. Reviewed and updated in November 2026, tested on Ubuntu 24.04 with sudo 1.9.15.
You type a sudo command, enter your password, and get this:
alice is not in the sudoers file.
This incident has been reported to the administrator.
Older sudo versions say This incident will be reported. instead. Same meaning: the password was right, but this account has no permission to use sudo. The fix is to give it that permission from an account that already has it, or as root.
The short version:
# Ubuntu / Debian (as root or another admin)
usermod -aG sudo alice
# RHEL, Rocky, AlmaLinux, Fedora
usermod -aG wheel alice
Then log out and log in again. That last step is where most people get stuck. I tested everything below on Ubuntu 24.04 with sudo 1.9.15.
Why it happens
sudo checks /etc/sudoers and the files in /etc/sudoers.d/. On Ubuntu, the default file contains these lines:
root ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
@includedir /etc/sudoers.d
%sudo means "members of the group sudo". So on Ubuntu and Debian, an account can use sudo if it's in the sudo group or has its own rule. On RHEL-family systems the group is wheel. Typical ways to end up without it:
- You created the account yourself with
useraddoradduser, which doesn't add any admin group. - You're on Debian and set a root password during install. Then the installer doesn't add your user to the sudo group.
- Someone ran
usermod -Gwithout-aand replaced all the user's groups.
Fix 1: add the user to the sudo or wheel group
You need a root shell or another sudo-capable account for this.
Ubuntu and Debian:
sudo usermod -aG sudo alice
RHEL, Rocky, AlmaLinux, CentOS, Fedora:
sudo usermod -aG wheel alice
The -a matters. Without it, -G sets the group list to just that one group and removes the user from every other group.
If you're logged in as root without sudo, drop the sudo in front. On Debian, become root with su - (with the dash). Plain su keeps your normal PATH, and then usermod isn't found because it lives in /usr/sbin.
Then start a new login
Group membership is read when you log in. A terminal that was already open keeps its old groups. I tested this: while a shell was open, I added the user to sudo, and sudo in that same shell still failed with "not in the sudoers file". A new login showed the group right away:
id -nG
alice sudo
So log out completely (or close the SSH session and reconnect), then try again:
sudo whoami
root
On a desktop, logging out of the session is enough. Opening a new terminal tab isn't.
Fix 2: give one user its own sudoers rule
Use this when you don't want a group, or need a narrower rule. Never edit /etc/sudoers directly with a normal editor. A typo there can lock every admin out of sudo. Use visudo, which checks the syntax before saving:
sudo visudo -f /etc/sudoers.d/alice
Add one line:
alice ALL=(ALL:ALL) ALL
In my test this worked without any group membership, and took effect immediately, no new login needed.
If you write the file another way, check it before it goes live:
sudo visudo -cf /etc/sudoers.d/alice
/etc/sudoers.d/alice: parsed OK
A broken line shows the exact spot instead:
/tmp/bad:1:21: syntax error
alice ALL=(ALL) ALL oops
^~~~
Files in /etc/sudoers.d/ should be owned by root with mode 0440. File names with a dot or ending in ~ are ignored, so alice.conf won't work, but alice will.
Passwordless sudo for automation accounts:
deploy ALL=(ALL) NOPASSWD: ALL
I'd only do that for service accounts that log in with SSH keys, never for a normal user with a password login.
Fix 3: create a new sudo user from scratch
If you're setting up a server and logged in as root:
Ubuntu / Debian:
adduser alice
usermod -aG sudo alice
RHEL / Rocky / AlmaLinux:
useradd -m alice
passwd alice
usermod -aG wheel alice
On RHEL-family systems the %wheel ALL=(ALL) ALL rule is enabled by default. Check with sudo grep wheel /etc/sudoers.
Test in a new login, not by switching user inside your root session:
su - alice
sudo ls -la /root
Once the new account works, it's a good moment to stop logging in as root over SSH. Set up key-based SSH login for the new user first. If you do need root over SSH, read how to allow SSH root login safely.
No admin account and no root password?
This happens when the only admin was removed from the sudo group by mistake, or on a Debian box where nobody remembers the root password. You need a way in that doesn't go through sudo:
- Root password known:
su -, then Fix 1. - Cloud VM: use the provider's web console, or the "reset password / run command" feature (cloud-init or the guest agent). Many providers can also inject an SSH key for root.
- Physical machine or VM console: boot into recovery mode. On Ubuntu, hold Shift or press Esc at boot, choose Advanced options → recovery mode → root. The disk is read-only there, so remount it first:
mount -o remount,rw /
usermod -aG sudo alice
reboot
If the GRUB menu has a password, or the disk is encrypted, you'll need that password too. That's the point of those protections.
Ubuntu 26.04: "I'm afraid I can't do that"
Ubuntu switched to sudo-rs, a Rust rewrite of sudo. It has been the default since 25.10, as announced on Ubuntu Discourse, and 26.04 keeps it. Its error text is different. When I tried sudo-rs as a user without rights, it printed:
sudo-rs: authentication failed: I'm sorry alice. I'm afraid I can't do that
It means exactly the same as "not in the sudoers file". sudo-rs reads the same /etc/sudoers and /etc/sudoers.d/, so the fixes above are identical. The classic sudo is still available as sudo.ws, but It's FOSS notes that switching back only works until Ubuntu 26.10. Switching wouldn't fix this error anyway, since both read the same rules.
Where "this incident" is reported
sudo logs the failed attempt through syslog:
# Ubuntu / Debian
sudo grep sudo /var/log/auth.log | tail
# RHEL family
sudo grep sudo /var/log/secure | tail
# any systemd system
sudo journalctl _COMM=sudo --since today
Nobody gets an email unless the server has a mail setup and sudo is configured to send one. On most servers, "reported" just means a log line.
FAQ
What does "user is not in the sudoers file. This incident will be reported" mean?
The account is allowed to log in but not to use sudo. Neither the user nor any of its groups has a rule in /etc/sudoers or /etc/sudoers.d/.
I added the user to the sudo group, but it still fails. Why?
The session still has the old group list. Log out and back in, then check id -nG. In my test, the already-open shell failed and a new login worked.
What's the difference between the sudo and wheel groups?
Just the name. Debian and Ubuntu use sudo, RHEL and Fedora use wheel. Both are enabled in the default sudoers file of their systems.
How do I add a user to sudoers without visudo?
Write a file in /etc/sudoers.d/ and check it with visudo -cf before relying on it. Editing /etc/sudoers directly without a check is how people break sudo for everyone.
How do I remove sudo rights again?
sudo gpasswd -d alice sudo (or wheel), and delete the user's file from /etc/sudoers.d/ if there is one.