You are not logged in.

#1 2006-11-24 09:41:02

cyberpatrol
Member
From: Germany
Registered: 2006-11-22
Posts: 68

visudo with nano?

Hi!

I'm currently giving Arch Linux a trial switching from Gentoo to it in mind. My first and second impression is that Arch Linux is a pretty good distribution and I already like it.

Nevertheless I have one problem with visudo.

On Gentoo it's possible to get visudo working with any other editor than vim, e.g. with nano. Only the environment variable EDITOR has to be set to "/usr/bin/nano".

On Arch Linux I installed sudo by running "pacman -S sudo" and also set the environment variable EDITOR to "/usr/bin/nano" but I'm getting this error message when starting visudo: "visudo: no editor found (editor path = /usr/bin/vi)"

So my question is: Is it on Arch Linux also possible to get visudo working with nano instead of vim and what do I need to do? Or am I forced to install vim to get visudo working?

Offline

#2 2006-11-24 09:53:42

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: visudo with nano?

It's possible, of course. man visudo, specifically the 2nd paragraph, explains it all.

Please note the security implications of rebuilding sudo to support the EDITOR environment variable.

Offline

#3 2006-11-24 14:50:52

cyberpatrol
Member
From: Germany
Registered: 2006-11-22
Posts: 68

Re: visudo with nano?

Thanks for your answer.

I'd of course read the man page but the only thing I understood is that there is a configure flag and that I had to recompile sudo to toggle it what I wanted to avoid. If I hadn't missed `man sudoers` I'd understood the whole paragraph especially the meaning and usage of the variables and flags which can be set in sudoers.  :oops:

Actually these are the lines I added to sudoers:

# Defaults specification

# Reset environment by default
Defaults      env_reset

# Set default EDITOR to nano, and do not allow visudo to use EDITOR/VISUAL.
Defaults      editor=/usr/bin/nano, !env_editor

I guess with these settings the security hole should be closed because sudoers can only be read and written by root.

Recompiling sudo isn't necessary with these sudoers settings. These changes can be made with nano itself without using visudo. Any other change should of course be made with visudo.

Offline

#4 2006-11-27 06:33:51

mpie
Member
From: 404 Not found
Registered: 2005-03-06
Posts: 649

Re: visudo with nano?

just open it with nano as root.....
it works

Offline

#5 2006-11-27 21:42:06

elasticdog
Member
From: Washington, USA
Registered: 2005-05-02
Posts: 995
Website

Re: visudo with nano?

mpie wrote:

just open it with nano as root.....
it works

You can do that, but it's not the best idea since visudo automatically checks syntax upon exit and will prompt you if something is wrong.  That way, it makes accidentally disabling sudo a lot more difficult.  Check out <code>man visudo</code> for more details.

Offline

#6 2006-12-02 06:59:08

cyberpatrol
Member
From: Germany
Registered: 2006-11-22
Posts: 68

Re: visudo with nano?

Of course it's not the best idea to edit sudoers directly without visudo but if one doesn't have vim installed and doesn't want to install it in favour of nano this is the only possibility to change the editor. And if you know that there's definitely no other user who could want to change sudoers at the same time and if you don't change anything else except the editor settings in sudoers then it shouldn't be a problem to edit sudoers directly without visudo.

Anything else, of course, should be done with visudo.

Offline

#7 2006-12-02 14:00:31

McQueen
Member
From: Arizona
Registered: 2006-03-20
Posts: 387

Re: visudo with nano?

cyberpatrol wrote:

Of course it's not the best idea to edit sudoers directly without visudo but if one doesn't have vim installed and doesn't want to install it in favour of nano this is the only possibility to change the editor.

Just changing the symlink of the vi executable to nano will system default to nano.


/path/to/Truth

Offline

#8 2006-12-02 19:24:53

cyberpatrol
Member
From: Germany
Registered: 2006-11-22
Posts: 68

Re: visudo with nano?

That's probably the best idea. I don't know why I didn't think of that.
Thank you for the hint, McQueen.

Offline

#9 2021-12-28 15:34:37

JKMooney
Member
Registered: 2021-10-23
Posts: 5

Re: visudo with nano?

This is an old thread but I just want to put a better answer here in case this comes up on a search down the road (like it did for me).

First off; DO NOT EDIT THE SUDOERS FILE WITHOUT VISUDO, at least don't do that unless you know how to use visudo -c to check the results after the fact.  However, reading though this thread, don't do that, use visudo.

Ok, that being said, everything I'm going to tell you can be found in the ArchWiki here:
https://wiki.archlinux.org/title/Sudo#Using_visudo

The ArchWiki can be a little confusing here because it gives you a couple of different ways to do it.  I'm going to break out what I think is the easiest way and, anything in curly brackets {..} was cut and pasted straight from the ArchWiki.

As it turns out, {The sudo package is compiled with --with-env-editor}

That means visudo on Arch will respect what you set as the global environment editor.  To set that, open (as root) /etc/environment and add "EDITOR=nano"
below is my copy of /etc/environment so you can see what it looks like.

==================================
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#
QT_QPA_PLATFORMTHEME=qt5ct
#QT_STYLE_OVERRIDE=kvantum
BROWSER=firefox
EDITOR=nano
=====================================

As you can see, I just added "EDITOR=nano" at the end.

Restart so all that can load and the next time you load visudo, it should just use nano.

BTW - I get the impression the OP tried this first and it didn't work out.  Not sure why, perhaps it wasn't compiled this way back in 2006?  What he ultimately wound up doing is the other way to do it (edit visudo to use nano as he described).

Last edited by JKMooney (2021-12-28 15:57:55)

Offline

#10 2021-12-28 15:55:38

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: visudo with nano?

Holy Necrobump Batman!

JKMooney wrote:

That means visudo on Arch will respect what you set as the global environment editor.  To set that, open (as root) /etc/environment and add "EDITOR=nano"

Not quite. It checks SUDO_EDITOR, then VISUAL and only uses EDITOR if the those are not set.

Offline

#11 2021-12-28 16:00:46

JKMooney
Member
Registered: 2021-10-23
Posts: 5

Re: visudo with nano?

Head_on_a_Stick wrote:

Holy Necrobump Batman!

JKMooney wrote:

That means visudo on Arch will respect what you set as the global environment editor.  To set that, open (as root) /etc/environment and add "EDITOR=nano"

Not quite. It checks SUDO_EDITOR, then VISUAL and only uses EDITOR if the those are not set.

Also in the Wiki and yes, you can optionally set those.  Again, multiple approaches.  The OP is coming from Gentoo and he ultimately solved it by editing the sudoers file to use nano.  He wasn't a "newbie", but there is some cringe-worthy advice in this thread.

Offline

#12 2021-12-28 16:15:26

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: visudo with nano?

Please pay attention to the age of topics before bumping them unnecessarily.

https://wiki.archlinux.org/title/Genera … bumping%22

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB