User is not in the sudoers file. This incident will be reported, while working with Ubuntu
I could get this error and no other command its allowing me to execute.
Error as shown in image – 1
Image – 1
Login to recovery mode (Click here – How to log in to recovery mode in Ubuntu)
And follow the steps to open Recovery Menu as this has tools which will help to recover the Operating system from error and as we have sudo error we can go and select root Drop to root shell prompt as shown in Image – 2
Image – 2
When you get terminal type below command to enable read write so that you can execute commands here
mount -o remount,rw /
To add the user in the sudoers file please do run below command
adduser username sudo
NB: here username is the current active user for which you are getting sudo error
let say machine user name is raj then command will be
adduser raj sudo
then you have successfully executed the command and run below command to exit
shutdown -r now
Now machine will reboot and then login with the same username having sudo error earlier.
Hopefully you will now be able to run sudo commands without any error.
You may also like: