Avoid Password Prompt When Executing The Sudo Command

If you have experience of working on the command line in Ubuntu then you are probably familiar with the sudo command, whenever you run the sudo command as a non root user then the system prompts you to enter the administrator’s password. This is a seriously annoying process.

Here is the simple tip which gets rid of this password prompt, follow these tweaks if you have a situation where you don’t want to enter the root password while running the sudo command as a non-root user.

You will need to modify a system file in this regard, so first open the terminal and run the following command to become the root user.

su

Once you are done,  go through the following steps to get rid of this annoying password prompt for the sudo command.

  • Assign the permissions to the sudoers file, by running the following command:

chmod 740 /etc/sudoers

  • Now edit the /etc/sudoers file and add the following line at the end of this file. (You can run gedit /etc/sudoers command to open the file for editing). Alternatively the best and secure way to edit the /etc/sudoers file is via visudo utility. You will need to run this utility from the command line, go to the /etc directory and run the command visudo. You will find the /etc/sudeors file opened. Add the lines as mentioned blow and then save the file by pressing ZZ or typing :wq! if you are in the command mode.

%admin ALL=(ALL) NOPASSWD: NOPASSWD: ALL

That’s it, now you will be able to run the sudo command as a non root user without being prompted to enter the password. It will literally save you time and increase productivity.

Update: Instead of using the Gedit to edit the sensitive sudeors file, we have included the visudo method which is more secure. Thanks to all commenters who pointed out the flaws.

قالب وردپرس

About Alyse Kalish

Alyse Kalish
As an Associate Editor for The SalesJobInfo, Alyse is proud to prove that yes, English majors can change the world. She calls many places home, including Illinois where she grew up and the small town of Hamilton where she attended Colgate University, but she was born to be a New Yorker. In addition to being an avid writer, Alyse loves to dance, both professionally and while waiting for the subway.

Leave a Reply

Your email address will not be published. Required fields are marked *