You are not logged in.

#1 2012-11-28 23:28:54

Zukaro
Member
From: Ontario, Canada
Registered: 2012-01-14
Posts: 32

Can't edit sudo

I've installed sudo but I can't use it on my user as I don't have the permissions to.  I've looked it up on Google and found I had to do visudo in order to edit the file and allow myself to use sudo on my other user.  But it wont let me edit anything.  I've heard you need to press insert to edit, so I did that and it let me delete stuff sorta (backspace key doesn't work but pressing the delete key does).  The problem is I can't actually type anything, when I try to I get graphical glitches and no text is entered.

Edit: nevermind; it suddenly started working (I literally didn't press anything, it just started co-operating after a few min).

Last edited by Zukaro (2012-11-28 23:32:54)

Offline

#2 2012-11-28 23:32:15

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: Can't edit sudo

man sudoers

/etc/sudoers can be edited with any text editor.

Last edited by Scimmia (2012-11-28 23:32:33)

Offline

#3 2012-11-28 23:34:04

Zukaro
Member
From: Ontario, Canada
Registered: 2012-01-14
Posts: 32

Re: Can't edit sudo

Scimmia wrote:

man sudoers

/etc/sudoers can be edited with any text editor.

The sudoers file said you have to use visudo otherwise you'll get errors, so I didn't try with that.  Thanks anyways though (next time I'll just do it that way and see what happens).

Either way visudo started working so it's fine now.  :3

Offline

#4 2012-11-28 23:38:36

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: Can't edit sudo

So...
How are you liking the vi text editor so far?

Offline

#5 2012-11-28 23:51:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Can't edit sudo

Technically you can edit the sudoers file with any text editor - but it's a very bad idea to try to open it directly.

However, if you were following any of the appropriate wiki pages you would have seen

# EDITOR=nano visudo

Normally we don't like to spoon-feed such information that is readily available in the wiki - but that one's a freebie, as I can rest assured that if you are not following the beginners guide you're sure to screw up your system in some other way.

Last edited by Trilby (2012-11-28 23:51:23)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2012-11-29 00:11:44

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: Can't edit sudo

Trilby wrote:

...

I am fairly sure that won't work unless you've configured /etc/sudoers to include the EDITOR environment:

# Use vim as editor
Defaults env_keep += "EDITOR VISUAL PAGER"

(Note: I personally added the above)

Offline

#7 2012-11-29 00:17:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Can't edit sudo

It will.  VISUAL and EDITOR are taken from the current environment by default.

This does depend on the compile time configuration of visudo - but the arch package includes this option.  You cannot set EDITOR to *anything* and have it work.  There is a finite list of accepted editors, I don't know what they all are, but nano is definitely on the list.

Last edited by Trilby (2012-11-29 00:20:10)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2012-11-29 00:28:40

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: Can't edit sudo

I know our sudo is compiled with --with-env-editor, however, this is the default sudoers file after building: http://ix.io/3wG

No where does it seems to allow the EDITIOR or VISUAL env and, although this was probably 2 years ago now, setting $EDITOR never worked for me. (At any rate, I'll take your word for it since it was a long time ago. Next time I tinker with a fresh sudoers, I'll try exporting vim.)

Last edited by Earnestly (2012-11-29 00:29:10)

Offline

#9 2012-11-29 00:33:34

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Can't edit sudo

@Kaustic, it works... I have been using vim with visudo since I installed this system... does yours not work?  Or have you not tried it recently? (I noticed you said someting about 2 years ago...)

Offline

#10 2012-11-29 00:36:56

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: Can't edit sudo

Yup, caveat emptor tongue
PS: In a sort of ironic twist of fate, I don't mind using vi anymore, hence why I haven't tried alternatives with any new installations. I'll make a note of it for next time.

Last edited by Earnestly (2012-11-29 00:39:46)

Offline

#11 2012-11-29 01:53:00

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: Can't edit sudo

Also works fine with vim set as EDITOR in the environment for me.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB