How Do You Fix the Problem of Being Prompted for the Root Password When You Want to sudo as a Given User?

Problem scenario
You try to run a command with sudo and you are prompted for the root user password (not the password for the username who issued the sudo command). You want to be prompted for the user (e.g., jdoe) not root.  What should you do?

Solution
Root cause
sudo is not configured properly.

Procedures
1.  Use the visudo command (with no arguments): visudo

2.  Comment the stanzas (place leading "#" symbols) in front of these stanzas:

Defaults targetpw
ALL    ALL=(ALL) ALL

They will look like this:

#Defaults targetpw
#ALL    ALL=(ALL) ALL

3.  Add the user to the "User privilege specification":

jdoe ALL=(ALL) ALL

4.  Save (e.g., press ZZ).

5.  You are done.  If you want to change the interval of how frequently you are prompted to enter a password (the time duration before being challenged again) when you use the sudo command, see this posting.

Leave a comment

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