Disable Password Authentication When Running ‘Sudo’ Command in Linux

When running a command with sudo at the beginning in Linux, it asks for typing user password. Once you entered the correct user password and hit Enter, it won’t ask again within a period of time (about 5 minutes).

The feature improves security since sudo is used to execute command as another user. For instance, when running command to refresh package cache, install an app, or edit a system configuration file, sudo will run the command with root, the super user privilege.

So removing the password authentication is not recommended and will put your system at risk! If you insist on doing so, keep reading …

Disable Sudo Password Authentication

In Linux, there’s /etc/sudoers configuration file that controls who can run what commands as what users on what machines and can also control special things such as whether you need a password for particular commands.

All you need to do is edit the sudoers file and change the rules.

1. Open terminal from your system application launcher. When it opens, run command to edit sudoers:

sudo visudo

Type your user password when it asks and hit Enter. The file should open in your terminal:

2. Next scroll down via Down arrow key on keyboard, find out the line:


And change it into:


3. Finally save the change by pressing Ctrl+X on keyboard, follow with Y, and finally hit Enter.

That’s it. Enjoy!

For any reason, you can restore the change by re-editing sudoers file and change the line back.

Merilyn Ne
Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.