nanosudo? (default update-alternatives --config editor choice)

Tom H tomh0665 at gmail.com
Tue Dec 25 03:27:03 UTC 2012


On Mon, Dec 24, 2012 at 11:10 AM, Phil Dobbin <bukowskiscat at gmail.com> wrote:
> On 12/24/2012 09:11 AM, Paul Sladen wrote:
>> On Mon, 24 Dec 2012, Phil Dobbin wrote:
>>>
>>> [is this] now standard Ubuntu policy to default to nano rather
>>> than vim (vi) for visudo
>>
>> I had a reinvestigate, rather than relying on my memory.  The
>> requirement is mandated in the following section of the Policy Manual:
>>
>>   Debian Policy Manual
>>   11.4 Editors and pagers
>>   http://www.debian.org/doc/debian-policy/ch-customized-programs.html#s11.4
>>   "‥every program that launches an editor or pager must use the
>>   EDITOR ‥ environment variable" and "[‥if] not set, the programs
>>   /usr/bin/editor ‥ should be used"
>>
>> So you are correct about EDITOR being unset.  Running
>> 'apt-get changelog sudo' brings up an interesting progression of bugs:
>>
>>   1.
>>     * enable ENV_EDITOR
>>   Fixed in sudo (1.4.1-1) on 1996-03-05.
>>
>>   2.
>>   "visudo does not default to vi"
>>   http://bugs.debian.org/388659
>>   Fixed in sudo (1.6.9p9-1) on 2007-12-03
>>
>>   3.
>>   "sudo: ignores configured editor preferences"
>>   http://bugs.debian.org/474197
>>   Fixed in sudo (1.6.9p15-2), on 2008-04-16 with a revert + rationale:
>>   * revert the fix for 388659 such that visudo once again defaults to
>>     using /usr/bin/editor.  I was always ambivalent about this change, it
>>     has caused more confusion and frustration than it cured, …"
>>
>>> so making the nano the default $EDITOR because
>>
>> So by this stage, $EDITOR should be respected, and if not set should
>> fallback to /usr/bin/editor, which should default to Nano. However, I
>> notice that as-of a couple of months ago, a bug has been opened:
>>
>>   "vipw uses vi by default; should use /usr/bin/editor"
>>   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=688252
>
> Whilst I can understand Ubuntu wanting to make things easier for people
> with regards to the default editor (many people are put off by vim it
> must be said), I can't help thinking it'd would've been better left as
> it was especially in cases like visudo (if you think about it, if you're
> using a desktop version of Ubuntu, you'd very rarely need to edit
> sudoers anyway.

(I find it "interesting" that 388659 changed visudo to use vi and that
474197 changed it to editor...)

Ubuntu's simply using Debian's default setup, "/usr/bin/editor", which
points to "/etc/alternatives/editor", which points to "/bin/nano". (Is
nano in "/bin" because it's the default or is it the default because
it's in "/bin"?)

If you want to change the editor for visudo only you can:

* use an alias for 'EDITOR=/bin/nano visudo' or 'VISUAL=/bin/nano
visudo' for one or all users

* set 'Defaults editor="/bin/nano" !env_editor' in
'/etc/sudoers.d/editor' for all users

If you want to change the editor overall you can export 'EDITOR=
/bin/nano' or 'VISUAL= /bin/nano' in '/etc/bash.bashrc',
'/etc/skel/.bashrc', or '~/.bashrc' for one or all users (if you set
both and set them to different editors, it's $VISUAL that's used)




More information about the ubuntu-users mailing list