Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As far as I know, the major difference is that visudo has a simple parser for seeing if /etc/sudoers (and other sudoers files) is goodly; however, I also noticed that, when I set EDITOR=emacs, sudoedit honours the change, however, visudo does not. From what I can tell, this is because visudo does not honour $EDITOR values unless they are listed in sudoers. What I want to know is if I can make sudoedit do the same thing, so as to not allow things like

Another thing I noticed, which seems related, is that as root (after su-ing as user jef), (with the line export EDITOR=emacs in /home/anachrome/.bashrc), both visudo and sudoedit use emacs as the editor, but when not su'd into root, only sudoedit uses it. I'm curious as to why this is (I presume it has something to do with sudo not actually resetting the evironment variables when sudoing as yourself (e.g. root $ sudo -u root), but this is just me assuming).

EDIT: The second question is apparently just because $EDITOR wasn't one of the variables kept by sudo.

And incidentally, I'm using Arch Linux, in case that's relevant.

share|improve this question
Wouldn't sudo env answer the second part of your question? – Daniel Beck Nov 19 '11 at 6:19
Ah. A quick check confirms that if I run something with 'sudo' EDITOR isn't used, while if I run something without, (i.e., I'm root and don't need sudo), EDITOR is preserved. Thanks for that. – Anachrome Nov 19 '11 at 23:05
You can configure which environment variables are considered safe in /etc/sudoers. All others are usually unset by sudo. – Daniel Beck Nov 20 '11 at 7:57
Yea, I figured that out now, my real question is: visudo, when determining which editor to use, only considers $EDITOR if it is in the list defined by Defaults editor=[...]. How can I make sudoedit mirror this behavior? – Anachrome Nov 20 '11 at 15:53

For me on Arch, neither visudo nor sudoedit honor $EDITOR but they do both honor $VISUAL, so maybe that's worth a try.

share|improve this answer

Also check that the desired editor is actually installed. Specifying EDITOR=vim when all you've got is vi.tiny won't give much joy.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .