How to configure passwordless sudo for a user in Linux

To learn more about the various syntax used in sudoers file follow below link

There is a parameter NOPASSWD which has to be used for your user to run allowed commands without providing their password everytime.

 

For example:
I want to all all the user of admin group to run bind services

# visudo
%admin  ALL=(ALL)       NOPASSWD: /etc/init.d/named reload

Verify the changes. Login as deepak and try to run the command

# su - deepak
[deepak@test2 ~]$ sudo /etc/init.d/named reload
Reloading named:                                           [  OK  ]

Now as we see it didn't prompted for password.

Just to allow a single user make the below changes

deepak  ALL=(ALL)       NOPASSWD: /etc/init.d/named reload

Allow the user to run all commands without getting prompted for password

deepak  ALL=(ALL)       NOPASSWD: ALL

I hope I made myself clear

 

Related Articles
How to give normal user root privileges using sudo in Linux/Unix

 

Leave a Comment