Meta

How to use visudo

If you don’t know what it is, you probably shouldn’t be using it. That said, to edit your /etc/sudoers file you need to use

sudo visudo

You have two “modes”
• Command mode – Press ‘ESC’ to access.
• Insert mode – Press ‘I’ to access.
You’re always in one or the other.

• To move the insertion point around, press ‘ESC’ and use the arrow keys.
• Once you’re where you want to be, press ‘I’ and start entering text.
• To delete a character, you need to be in command mode, select the character and press the delete key. (Note: not the Backspace key) You can do this in insert mode, but it does some funky things with the text.
• To save your changes, in command mode, type :w and press enter.
• To quit, in command mode, type :q and press enter.
• To quit without saving any changes, in command mode, type :q! and press enter.

Be careful, if you mess it up, you will no longer be able to sudo. Then you need to sudo to fix it. Bit of a problem there. To fix it, you need to login as root, run visudo, and fix the file.

This was helpful. Thanks for posting it. For some reason I couldn’t delete text correctly until I realized I had to type ‘d’ and then press the right arrow. Pressing ‘d’ then down would delete a whole line! ‘Vi’va la Emacs!