Ubuntu – Must use ‘visudo’


In /etc/sudoers, it says:

# This file MUST be edited with the 'visudo' command as root.

My question is, why must this file be edited with visudo?

It seems I was able to edit the file successfully with gedit, by issuing:
sudo gedit /etc/sudoers.

If I was able to edit it with gedit, why must I use visudo?

Best Answer

It is just safer to use visudo. You can edit /etc/sudoers directly, but if you make a typo there, you will not be able to use sudo anymore. And won't be able to fix your error.

visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors.

You can read more by:

man visudo
Related Question