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

  • Resolving Missing Memory Stats in Docker Stats on Raspberry Pi

    Running Docker containers on your Raspberry Pi can be a great way to explore different software and services. However, encountering issues with retrieving memory usage information using docker stats can be frustrating. In this blog post will dive into the common reasons behind missing memory stats and guide you through the troubleshooting steps to resolve them.

  • 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.

  • 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.