sudo – How to Verify if Sudo is Working Correctly

rebootrecovery-modesudo

I don't know what's wrong in my pc. It runs on Ubuntu 16.04.

When I give sudo command, it asks for password. When I give password, it does not accept.

sudo -i
[sudo] password for alpha: 
Sorry, try again.
[sudo] password for alpha: 
Sorry, try again.
[sudo] password for alpha: 
sudo: 3 incorrect password attempts
alpha@alpha-Inspiron-15-3567:~$ 

The password is correct, I checked that. The keyboard layout is okay, I typed the exact password.

To fix this I tried to follow this: Cannot run any sudo command

The Simple fix one did not work, so I tried the complex fix one, rebooting in recovery mode.
Got to this step:

recovery menu

bit I could not enter the whole command of

mount -o remount,rw /
chmod chmod u=rwxs,g=rx,o=rx /usr/bin/sudo /usr/bin/pkexec
exit

before I could complete /usr/bin/sudo, it started to run commands on its own and resumed.
So, here I am, not understanding anything. Can anybody help me ?

Best Answer

You are executing these commands from a root shell prompt, so you don't need to preface the commands with sudo and you don't need to run sudo -i at all because you are already root.

The command in this answer is incorrect because chmod is repeated twice:

chmod chmod u=rwxs,g=rx,o=rx /usr/bin/sudo /usr/bin/pkexec  

The correct command is:

chmod u=rwxs,g=rx,o=rx /usr/bin/sudo /usr/bin/pkexec  
Related Question