How to enable passwordless sudo in Linux
sudo
is a program that allows a user to run programs with the security privileges of another user. If no user is specified, it will try to run the other program as root
, or the superuser
. By default, running sudo
will prompt for the superuser
password, as in the following example;
shakir@anduril:~$ sudo vi /etc/resolv.conf We assume you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. Password:
While this is good for security reason, normal users would want to avoid the password prompt completely, especially if they are just running it on a desktop.
To enable passwordless sudo
, one need to edit the /etc/sudoers
file. This can be done by directly editing the file using your favorite editor as the following;
This method is known to cause problems with Ubuntu. Consider using the second method.
$ sudo vi /etc/sudoers
or by using a dedicated program just for this by issuing the following command;
$ su - # visudo
In editing the file, there are 2 options to enable passwordless sudo
, which is to allow by group
, or by user
.
To everyone in the group mygroup
to be able to use sudo
without password, add the following line;
%mygroup ALL=NOPASSWD: ALL
Adding the following line will allow the user shakir
to use sudo
without password
shakir ALL=NOPASSWD: ALL