How can I log in with a sudo user without a password?

On Linux platforms, sudo is a tool that implies “superuser do” for executing various system commands. The sudo user is usually the root user or any other user with some privileges. To delegate important tasks, such as restarting the server or restarting the Apache server, or even to create a backup using the sudo command, you can use sudo without having to enter your password over and over again.

By default, the sudo user needs to be given some authentication. Sometimes users need to run a command with these root privileges, but they don’t want to enter the password multiple times, especially while scripting. This is easy to do on Linux systems. In this article, we will test another user’s sudo method without entering their password.

Running sudo command without password

To back up your sudo users, you need to copy the / etc / sudoers file from one location to another. To do this, use the following command:

$ sudo cp /etc/sudoers /root/sudoers.bak

Now, to edit the / etc / sudoers file, we will use the visudo command. This will open the sudoers file.

$ sudo visudo

To edit the / etc / sudoers file, users need to modify the entries to suit your needs. Adding another user to sudo will allow users to run any command without a password. In the file above, add the following command.

UserName ALL = NOPASSWD: /bin/systemctl restart httpd.service, /bin/kill

Replace UserName with the name of the user you want to include in the file.

Then save and exit the file with the keyboard shortcut Ctrl + O.

Run ALL sudo commands without password

To add a group to sudo without entering a password, use the% character in front of your group name. But first open the visudo editor using the command below:

$ sudo visudo

After you have opened the editor window, you need to add the following line to add a group and execute all commands without a password.


Here replace the group name with the group for which you want to configure the settings.

Allowing the user to run / bin / kill

To allow the user to run the / bin / kill command with sudo privileges without entering a password, add the following line in the same editor window:

UserName ALL=(ALL) NOPASSWD: /bin/kill

Replace UserName with the username for which you want to change the settings.

In the same way, so that group members can run the sudo / bin / kill, / bin / rm commands without having to enter any password, run the added command:

%group ALL=(ALL) NOPASSWD: /bin/kill, /bill/rm

Testing changes

To test the changes, you can now run the / bin / kill command, which will be used to terminate any process whose ID is specified. You won’t need a password this time:

$ sudo /bin/kill PID


In this article, we have seen a method to run any command without providing a password when using sudo on different Linux platforms. While this is considered risky from a security standpoint, passwordless operations are dangerous and an additional feature for secure systems.