How to Fix ‘user is not in the sudoers file. This incident will be reported’ in Linux

Executing an administrative command with sudo on a fresh Linux installation only to see the warning: username is not in the sudoers file. This incident will be reported is a common rite of passage for Linux system administrators. This security warning indicates that the active user account lacks administrative privileges in the /etc/sudoers policy file. Consequently, the operating system blocks the command and logs an audit security event to /var/log/auth.log (or /var/log/secure). Resolving this restriction requires authenticating as the root user or booting into recovery mode to add your account to the administrative group.

Understanding Sudoers Access Control in Linux

The sudo (superuser do) utility relies on /etc/sudoers to determine which users and groups can elevate privileges. Access is typically granted through dedicated system groups:

  • Ubuntu and Debian: Members of the sudo group are automatically granted administrative elevation privileges.
  • RHEL, CentOS, Fedora, and Rocky Linux: Members of the wheel group are granted full sudo administrative access.
  • The Incident Reporting Log: The phrase ‘This incident will be reported’ refers to an internal log entry written to local system journals, not an external notification to third parties.

Solution 1: Switch to Root and Add User to the Sudo Group (Ubuntu/Debian)

If you know the system’s root password, switch to the root shell and append your user account to the sudo group.

  1. In your terminal, elevate to the root shell using su:
    su -
  2. Enter the root account password when prompted.
  3. Execute the usermod command to append your username to the sudo group:
    usermod -aG sudo your_username
  4. Replace your_username with your actual Linux user account name.
  5. Verify the group assignment:
    groups your_username
  6. Exit the root shell by typing exit.
  7. Important: Log out of your desktop or SSH session completely and log back in for new group memberships to take effect.

Solution 2: Add User to the Wheel Group (RHEL/Fedora/CentOS)

Red Hat enterprise distributions utilize the wheel group to administer superuser authority.

  1. Switch to the root user:
    su -
  2. Add your user account to the wheel group:
    usermod -aG wheel your_username
  3. Verify that the wheel group rule is enabled in /etc/sudoers using visudo:
    visudo
  4. Confirm that this line is uncommented (does not begin with a #):
    %wheel ALL=(ALL:ALL) ALL
  5. Save and exit (in nano: Ctrl + O, Enter, Ctrl + X; in vi: Esc, :wq, Enter).
  6. Log out and log back in to test sudo whoami.

Solution 3: Grant Sudo Access via GRUB Recovery Mode (Forgotten Root Password)

If the root account is locked or you do not have the root password, booting into single-user recovery mode provides a root command prompt.

  1. Reboot your physical computer or virtual machine.
  2. During startup, hold Shift (or press Esc) to display the GRUB boot menu.
  3. Highlight your kernel and select Advanced options for Ubuntu.
  4. Select the entry ending with (recovery mode).
  5. In the Recovery Menu, choose root – Drop to root shell prompt.
  6. Remount the filesystem as read-write:
    mount -o remount,rw /
  7. Add your user to the administrative group:
    usermod -aG sudo your_username
  8. Reboot the system normally:
    reboot
  9. Log into your standard user account. You will now possess full sudo execution authority.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.