Saturday, November 7, 2009

Changing Default Editor for visudo

Instead of editing /etc/sudoers directly, it is better to edit /etc/sudoers by using visudo.

The beauty of visudo is  that visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors. Look at man page for more information.

However, visudo uses nano as a default editor. How do I change the editor as I'm very used to vi or vim to do my editing. Here is a simple way of doing.

Put the following inside your .bashrc file
# vim .bashrc

export EDITOR=vim
sudo visudo

# source .bashrc

You should be able to use vim as the default editor for visudo

No comments: