Fix Sudo not asking Password on Raspberry Pi

📆 · ⏳ 1 min read · · 👀

Introduction

When you install a fresh copy of Debian or Raspbian on your Raspberry Pi you might notice that sudo does not ask for a password. This is a security risk and should be fixed. Let’s see how to fix it.

Fix Sudo not asking Password on Raspberry Pi

This happens due to the NOPASSWD option for your user. We need to make sure that this option is not set.

We will edit the file named 010_pi-nopasswd. To find its location we will use the find command.

Terminal window
sudo find / -name 010_pi-nopasswd

This will return the location of the file. In my case it is /etc/sudoers.d/010_pi-nopasswd. Now we will edit this file using visudo.

Terminal window
sudo visudo /etc/sudoers.d/010_pi-nopasswd

The current content on the file will look like this.

Terminal window
<username> ALL=(ALL) NOPASSWD: ALL

Where <username> is your username. We need to remove the NOPASSWD option. So the file will look like this.

Terminal window
<username> ALL=(ALL) ALL

Save the file and exit. Now when you run sudo it will ask for a password.

Conclusion

We looked into how to fix sudo not asking password on Raspberry Pi. This is a security risk and should be fixed. If you have any questions feel free to contact me here.

See you in another one. Bye 👋

You may also like

  • # raspberrypi

    Increase Swap Memory on Raspberry Pi

    There can be multiple scenarios where you need to increase the swap memory size on your Raspberry Pi. This post will show you how to do it.

  • # raspberrypi

    Update Wifi Password on Raspberry Pi in Headless Mode

    Changing the wifi password after the first installation can be tricky sometimes. Here is a quick guide on how to do it quickly and easily.

  • # nodejs# raspberrypi

    Get Up and Running with the Latest Version of Node.js on Raspberry Pi

    Do you want to run the latest version of Node.js on your Raspberry Pi? This guide will take you through the process of installing the latest version of Node.js on armhf architecture using binary packages.