How to Setup Sudo No Password in Linux

7

When a user executes the command with the sudo privileges, it asks for the password to run it and confirms the user’s request to perform that specific function from the file sudoers.

The Sudoers is the administrator’s file used for system configuration. System administrators can give access to the users to run some specific command or all commands. It keeps all the records in it about what and when things are done by whom.

It is good to set the password when you have multiple users in a single account. But when you’re the only user of a system and use it as a root user, typing the password multiple times for sudo privileges could irritate you. So, instead of entering the password even for a single function, it is better to set sudo without a password.

You can do it using the etc/sudoers file as we will discuss below.

How to Setup Sudo No Password

To set sudo without entering the password is a straightforward way that you don’t need to worry about. Just follow the steps carefully:

Step 1:

Open the terminal and type the following command to get /etc/sudoers file:

Enter the credential i.e. password to get the file:

Step 2:

Scroll down till the end of the /etc/sudoers file and append the mentioned below line:

$ wardah ALL=(ALL) NOPASSWD:ALL

(The mentioned line should be written at the end of the file so the other directives couldn’t be overridden with this)

Note: wardah is the username in my Linux system. You will write your username here.

Press Ctrl+s to save the /etc/sudoers file and then Ctrl+x to exit it.

Let’s run an example that needs Sudo privileges in command.

Example1:

Run the given command in terminal to install pip package through python:

$ sudo apt install python3-pip

Example2:

Execute the update command to update all packages available in the Linux system:

As you can see in both of the mentioned examples, after setting no password in sudo privileges, it won’t ask you to enter the password again while executing commands.

Conclusion:

Entering a password all the time with the Sudo command is irritating when you’re the only user. We can set the Sudo without a password using the /etc/sudoers file. The sudoers is the system administration configuration file having all the information about the user, what, and when they performed in the system.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More