DEV Community

Daniel Pepuho
Daniel Pepuho

Posted on • Edited on

How to enable passwordless sudo in Linux

I can show you many steps to configure passwordless sudo for specific user:

1.open your terminal and type this to add new user:

$ sudo adduser ansible
Adding user `demo' ...
Adding new group `demo' (1004) ...
Adding new user `demo' (1004) with group `demo' ...
Creating home directory `/home/demo' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for demo
Enter the new value, or press ENTER for the default
    Full Name []: 
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] y
Enter fullscreen mode Exit fullscreen mode

2.after that type:

$ sudo visudo
Enter fullscreen mode Exit fullscreen mode

3.go down to the bottom, then add this to assign a new user become sudo:

ansible ALL=(ALL) NOPASSWD:ALL
Enter fullscreen mode Exit fullscreen mode

4.done, now you have new user, that will able to execute sudo command without providing a sudo password.

N/B: in Debian you must install sudo:

$ apt install sudo

Enter fullscreen mode Exit fullscreen mode

Top comments (0)