How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu

How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu

How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu.

Are you having an error something like “Username is not in the sudoers file. This incident will be reported” in Ubuntu” then this post is for you as we will show you the reason behind the error and also solution to fix it.

How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu

Reason for the error “Username is not in the sudoers file. This incident will be reported” in Ubuntu”

  1. The permission on /etc/sudoers file is not set to 0440.
  2. user is not in sudo or admin group
  3. sudo Privileges error

Let’s have a look into the fix for this error.

At first, you need to restart your PC or laptop. You need to press the Shift key immediately for a few seconds to get the Grub boot menu. If you are using Ubuntu then You need to select “Advanced options for Ubuntu” and press Enter. In the next window, select the kernel with the “recovery mode” option and press Enter to advance to the “Recovery menu”. In the next window, you need to select  “root Drop to root shell prompt”, then hit Enter.

READ More Relevant Stuff:  How To Enable PPP on Ubuntu on Linux

Next, press Enter for maintenance. Now run the following command in the shell mode to change filesystem mode to read/write from read only mode.

read/write by running the command below:

# mount -o rw,remount /

Add User to sudo or admin Group

Run the following command to add the user to the sudo or admin group.

# adduser user_name sudo

Grant sudo Privileges to Users

Open the sudoers file.

# visudo

and add the following content in the sudoers file:

#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbi$

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

Setting Correct Permission on sudoers File

Run the following command to set the permission on sudoers file to 0440.

# chmod  0440  /etc/sudoers

Now, exit from the “Recovery menu” and reboot your Ubuntu

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *