How to Run sudo Command Without a password?

In Linux, “sudo” represents the “SuperUser DO” and is the keyword used to perform administrative tasks through the terminal. Only the users having administrative privileges can use the sudo keyword. While using “sudo”, an admin password is required to perform that operation; without this, the operation cannot be performed. However, there is also a way to run the sudo command without a password which we will demonstrate here. 

This guide will teach you to run the sudo command without a password.

How to Run sudo Command Without a Password?

Suppose the user wants to update the system repository via the “apt” command. The user must know about the “root-user” password to start the possess as shown below:

$ sudo apt update

The above command needs the root user password to update the current System repository. To run the “sudo” command without a password, follow the steps below:

Step 1: Log in to the Root User

The first step is to press the shortcut key “Ctrl+Alt+T” to open the Command Line terminal. Log in as a root user using the “su –” command as shown below:

$ su -

Step 2: Open the Sudoers File Script

Open the “sudoers” file in the default text editor “nano”. The “sudoers” file can be opened by typing the below-mentioned “visudo” command:

$ visudo

Step 3: Modify the Sudoers File Script

The “sudoers” file has been opened in the “nano” editor. Scroll down the window and move to the end of the file. After that, add the below-specified line at the bottom:

itxlinuxfoss ALL=(ALL) NOPASSWD: ALL

The “itslinuxfoss” is the username. The username can be changed and take access to run the operations without the root user password.

Step 4: Save the New Changes

Press the “Ctrl+S” to save the new changes. The “sudoers” file is now modified according to the requirements:

After that, exit the “nano” editor using the “Ctrl+X” shortcut key.

Step 5: Run the Sudo Command

Now run the “sudo” command with any specified operation and see the results. In this example, we will install the “youtube-dl” package using the “sudo” command:

$ sudo apt install curl

Now, the “sudo” command ran without a password and installed the “curl” package in the entire system.

That’s how you can bypass the sudo password.

Conclusion

The “sudo” command can be run without a password by modifying the “sudoers” file script with “<username> ALL=(ALL) NOPASSWD: ALL”. The “sudoers” file script is edited in the default “nano” editor using the “visudo” command. Once the changes are saved, the “sudo” command can run and execute the operations without a user password. This post has described the step-by-step guideline for running a “sudo” command without a password.