You probably know that in Ubuntu/Debian, you should not run as the root user, but should use the sudo command instead to run commands that require root privileges. However, it can also be inconvenient to have to enter your password every time that you use sudo. Here’s a quick fix that removes the requirement to enter you password for sudo.
- Open the
/etc/sudoersfile (asroot, of course!) by running:1
sudovisudoYou should never edit
/etc/sudoerswith a regular text editor, such as Vim or nano, because they do not validate the syntax like thevisudoeditor. - At the end of the
/etc/sudoersfile add this line:1
username ALL=(ALL) NOPASSWD:ALLReplace
usernamewith your account username, of course. Save the file and exit with<ESC>wq. If you have any sort of syntax problem,visudowill warn you and you can abort the change or open the file for editing again.It is important to add this line at the end of the file, so that the other permissions do not override this directive, since they are processed in order.
- Finally, open a new terminal window and run a command that requires
rootprivileges, such assudo apt-get update. You should not be prompted for your password!