Passwordless sudo for your desktop and servers

Once you setup it, you don't need to type passwords anymore. You do need to make sure it's only you who can access it though.

Updated

#passwordless#sudo#linux

I don’t really like typing my password every time I run sudo. Yes, I know it’s really bad to run sudo commands but I also know it’s equally bad to run rm -rf ~/ and I did that just couple of days ago accidently.

Working principle

Add following line in /etc/sudoers. Replace it if it already exists. The starting of the line is the username.

#/etc/sudoers
...
dineshdb  ALL=(ALL) NOPASSWD: ALL

Yep. That’s it. You go to the line for your target user and replace it with something similar. Remember the NOPASSWD: ALL bit. Spaces and tabs matter.


Headshot of Dinesh Bhattarai

Hi, I'm Dinesh. I'm a software engineer based in Kathmandu. You can connect with me on Linkedin, see some of my work on GitHub, or read more about me on dbhattarai.info.np.