On Debian, sudo asks for user password by default. On Raspberry Pi OS, it doesn't.

How to configure sudo to ask for user password?

  • Edit /etc/sudoers.d/010-pi-nopasswd. The no password setting is in there.
    – Dougie
    Feb 24, 2021 at 17:39

1 Answer 1


Edit /etc/sudoers.d/010_pi-nopasswd and remove NOPASSWD word from it.

Be careful if you edit it using a regular text editor: if you make a mistake, save the file and quit, you will end up with a broken sudo and no way to edit the configuration again (which requires sudo).

Either don't close the editor until you have tested the new configuration, or have a root session open in another terminal just in case, or use visudo to edit the file (visudo refuses to save files if there are syntax errors). You can also set a password for root which lets you login as root and recover your system.

  • Thanks! Is it OK to delete this file?
    – sunknudsen
    Feb 22, 2021 at 12:21
  • I ran sudo rm /etc/sudoers.d/010_* and so far everything works fine.
    – sunknudsen
    Feb 22, 2021 at 12:26
  • 1
    @sunknudsen Yeah, the pi user also belongs to the sudo group, so it will fall back to the group policy if you remove that file. My only fear is that apt may recreate that file again during an upgrade. If you modify it, apt will not touch it without asking you. Feb 22, 2021 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.