Howtodojo logo
  • Home 
  • About 
  • Certifications 
  • Sample Database 
  • Cheatsheet 
  • Glossary 
  • Blog 
  • Tags 
  1.   Blog
  1. Home
  2. Blog
  3. How To Enable Passwordless Sudo in Ubuntu

How To Enable Passwordless Sudo in Ubuntu

Share via
Howtodojo
Link copied to clipboard

In this tutorial we learn how to enable passwordless sudo for specific user in Ubuntu. You can follow this tutorial in any Ubuntu versions.

How To Enable Passwordless Sudo in Ubuntu

In this tutorial we learn how to enable passwordless sudo in Ubuntu. I use Ubuntu 20.04 for this tutorial, but you should be able to follow this tutorial on older versions of Ubuntu like Ubuntu 18.04 or newer version like Ubuntu 20.04 or Ubuntu 21.04.

The main sudo configuration in Ubuntu is located in /etc/sudoers. This file contains the following line

#includedir /etc/sudoers.d
```bash

which will include any file in the `/etc/sudoers.d` directory that do not end with `~` or contain `.` (dot).

To enable passwordless sudo for spesific user, we can create new file in `/etc/sudoers.d/` directory. I recommend creating one file for each user for easy to manage access.

In the following example I will allow passwordless sudo for username `howtodojo`.

Edit the new file using `visudo` command. While this is not mandatory but visudo can help you ensure that the sudo configuration that you're editing is correct.

Error in sudoers files can lead to losing access to the system.

We can use the following command to edit the new file `/etc/sudoers.d/howtodojo`

```bash
sudo visudo /etc/sudoers.d/howtodojo

Enter the following configuration. Replace the <username> below with your username.

username ALL=(ALL) NOPASSWD: ALL
```bash

If you use default editor, nano, you can press `CTRL+X`, then choose `Y`. Now your username already have passwordless sudo on the system.

You can [change visudo default editor][1] if you prefer another editor when editing `sudoers` file.

 [1]: https://www.howtodojo.com/change-visudo-default-editor/
 How To Install Virtualbox on Ubuntu 20.04
How To Change Visudo Default Editor 
Follow me

We publish tutorials, tips and tricks about Linux, open source, cloud computing, and infrastructure

     
Copyright © 2012 - 2025 howtodojo.com. |
Howtodojo
Code copied to clipboard