visudo is a special tool in Unix/Linux for safely updating the /etc/sudoers file, used by the sudo command for providing and managing privileged access.
for safely updating the /etc/sudoers file, found in most Linux systems (Ubuntu for example).
Here’s what the Ubuntu Linux man page says about visudo:
Since /etc/sudoers file defines rules for (sometimes passwordless) access to privileged access, you can only run visudo as root.
In fact, if you attempt running visudo as a regular user, you will get an error (because visudo needs to access /etc/sudoers file):
You don’t need to specify any command line options. Just become root and run the command. You’ll be shown your default text editor window with the /etc/sudoers file (as shown on the screenshot at the top of this page).
If you inspect the screenshot carefully, you’ll notice the first important reason visudo command is so useful: it doesn’t edit the /etc/sudoers file directly. Instead, it makes a copy of it, called /etc/sudoers.tmp, and allows you to edit it. This means that if something happens to your editing session (server crashes, power goes, connection to remote server gets broken), there is no risk of leaving your server in a random security state /etc/sudoers wise.
Once you finish editing, visudo will perform a number of checks on the resulting /etc/sudoers.tmp file before appying its changes into /etc/sudoers file. If an issue is found, you’ll get the message about it after you save the file and exit your text editor:
Just press Enter to see the options:
Most likely you’ll want to press e to continue editing the file. But if you can’t find what’s wrong (it may well be that /etc/sudoers was broken by someone else before you, because – you guessed it – they edited file manually instead of using visudo) – if that’s the case, you may just press x to exit and to investigate the /etc/sudoers file more.