Tired of having to provide a password to use sudo on Linux?

I know I am…

Photo by Mike Szczepanski on Unsplash

Invariably when I log into one of my linux servers over an SSH terminal, I end up wanting to modify some files that require root permissions. So I insert the necessary sudo command at the front of the line and proceed. However, I tend to use randomized passwords and it’s always a pain to look them up.

For this brief note, I’m using an Ubuntu v18.04.4 linux server. If you want to check your operating system version in linux, just execute the following command:

cat /etc/os-release

You should see some output such as:

VERSION="18.04.4 LTS (Bionic Beaver)"
PRETTY_NAME="Ubuntu 18.04.4 LTS"

Now whenever I am working with a new server, I setup a non-root user as best practice, which is why I end up getting prompted to enter a password whenever using sudo. For this example, let’s pretend our username is bobrobot. What we need to do is add a line into a file located at /etc/sudoers that allows bobrobot to execute sudo (i.e. superuser do) without being questioned.

Go ahead and choose your favorite text editor (e.g. emacs, vim, or nano) and open up this file:

sudo vim /etc/sudoers

You should see a comment near the bottom of this file that looks like

#includedir /etc/sudoers.d.

Directly below this line, go ahead and insert the following (using your username instead of bobrobot):


Save and exit the file. You may need to logout and back in before the changes come into effect. That’s it!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store