Take the 2-minute tour ×

The scenario is this:

  • I have a development machine I want (need) to have root access to
  • Our admin setups the machines using his own credentials for the root user. The explanation being that if something goes wrong or he needs to change something he just have to remember one password
  • He then proceeds to give each user access to "sudo" without questioning for the password

Now I really dislike the fact that sudo wouldn't prompt me for my password. How does a user configuration look like that gives me and the admin complete root permissions (2 logins), with sudo prompting me for my password (and not root) look like?

share|improve this question
Yeah. It is a little confusing. I don't often have to use sudo and having a password needed for it acts as a good safeguard for not ruining stuff. I can't use the password from root as its the sysadmins default password. He won't give the password to me, but he is ok with me running every command with sudo. –  oschrenk Oct 27 '11 at 13:50
Which distro are you using? –  quanta Oct 27 '11 at 14:16
I'm running OpenSuse 11.2 –  oschrenk Oct 27 '11 at 14:36
add comment

3 Answers

up vote 5 down vote accepted

Type visudo, you will see something like this:

<your_user>  ALL=(ALL)   NOPASSWD:ALL

If you want sudo prompt for a password, just remove NOPASSWD

<your_user>  ALL=(ALL)   ALL


As @MikeyB mentioned, by default, sudo will prompt for a password of the invoking user. But if you turn on the targetpw flag:

Defaults targetpw

sudo will ask for the password of the target user.

share|improve this answer
But then it will prompt me for root's password which I don't have. I want it to prompt for mine –  oschrenk Oct 27 '11 at 13:59
No - it will prompt you for your password. Sudo does not use the root password at all, only su does that. –  pauska Oct 27 '11 at 14:03
No, you are wrong. It will prompt you for your password, not root. –  quanta Oct 27 '11 at 14:05
I got to admit that I'm not that familiar with unix security model but this is what the terminal says after I changed <your_user> ALL=(ALL) NOPASSWD:ALL to <your_user> ALL=(ALL) ALL: touch file, sudo rm file $ root's password: and when I type in my own it states Sorry, try again –  oschrenk Oct 27 '11 at 14:12
Ah, in your particular file the targetpw option is turned on. –  MikeyB Oct 27 '11 at 14:33
show 5 more comments

The answer lies in the sudoers(5) file, which you edit using visudo(8).

As the exmaples there show you, your current sudoers setup will look like this:


You can change this to:

%wheel ALL = (ALL) ALL

share|improve this answer
add comment

This is just a remark... Some people new with sudo may do the following mistake : sudo -u root -i or sudo -s or sudo -i -->which has the effect to ask your own password, and then if you re successful give you a brand new shell environment(/bin/bash) running with root privilege... Wonderfull... yeah, BUT then the "sudo-newbie" wants to create a file...and he type the following : sudo touch myEpicStoriesWithSudo.txt

--> Of course now sudo will ask for a password... but not your own!!! the one of root because you were not you --> you were root

And you can replace root by any generic-user you want, I had the issue with a lot of DBA when we went to sudo "sudo -u oracle -i" ;)

I hope this can helps you with sudo and all the schizophrenic issue that come with it ;) Regards

share|improve this answer
add comment

Your Answer


