If you are using the Linux operating system in your system which does not need much security or you know there is no threat if you allow running the sudo command without any password, then this guide will be helpful for you. Before doing this, let’s just understand a few basic things in the next sections.
What is sudo
As a root user or superuser, you are permitted to do anything like executing a program, editing a configuration file, etc. However, if you are a normal user you will be restricted with such permissions. To perform tasks like installation or removal of a package or editing a configuration file you need to have the superuser’s privilege. You can execute a command with superuser privileges by using sudo.
Sudo is a computer program in Unix or BSD operating systems. It allows a user to run a program with the security privileges of the superuser. For security purposes, it does logging of each command and argument which can be used later to see who did what?
How to configure to run sudo without password or passwordless
When you execute a command with sudo it will prompt for the user password. Once you enter the password and press the return key that command will get executed. This requirement of the password can be removed for a specific user by using the following steps-
- Sudo has a configuration file also known as the sudoers file which is typically located at /etc/sudoers. Edit the sudo’s configuration file by using the following command –
sudo nano /etc/sudoers
This command will prompt for the password once you enter and press the return key it will open the sudo configuration file in the terminal by using the nano text editor. The configuration file of sudo will look something like this –
- Now find a line that contains
#includedir /etc/sudoers.dProbably you will find it at the bottom of this configuration file.
- Now below the
#includedir /etc/sudoers.dadd the following lines
username ALL=(ALL) NOPASSWD:ALL
Replace the username with the username present on the system. In my case, I will add the below line in my system where lalit is the username-
lalit ALL =(ALL) NOPASSWD:ALL
- And finally, save the changes by pressing ctrl+s and then press ctrl+x to exit from the nano text editor. And now you can execute a sudo command without entering the user password.
If you want to configure it for another user you can do this by following all the steps that are given above.
Now if you want a command executing with sudo should ask for the password again, simply open the configuration file using a text editor and remove that line you have added. Once you save the changes and execute a command with sudo it will again start asking for the password.