# [Solved] Can't get visudo to work

## crystalattice

Just installed Gentoo and tired of switching to root to make admin changes and edit config files.  However, I can't use sudo, apparently because I'm not part of the wheel group.  I checked the documenation and found out I need to add myself to the wheel group by using visudo.  However, everytime I run the command I get the error:  "visudo: specified editor (/usr/bin/emacs) doesn't exist!".  I've installed emacs, vim, and sudo and I still can't get it to work.  From what I've read, it sounds like I should just be able to install sudo then run visudo but obviously it's not working.  What am I missing?

Thanks.

----------

## gentoo_dude

To add your username to wheel group do don't use visudo, but edit the /etc/group file as root

```

vi(or emacs) /etc/group

```

and where it lists wheel:<put your user name>

log out and log back in and it should work

----------

## didl

You can also use usermod to modify user accounts. See

```

man usermod

```

for more details.

----------

## crystalattice

Well, I checked which groups I belong to and found out that I am part of the wheel group.  Apparently I did that during the install process and forgot about it.  So why wouldn't I be able to use sudo?  And I still can't use visudo.  Any other suggestions?

Thanks for your help and quick responses.

----------

## hw-tph

 *crystalattice wrote:*   

> "visudo: specified editor (/usr/bin/emacs) doesn't exist!"

 

Do you like the nano editor? EDITOR=/bin/nano visudo should do the trick. You can specify $EDITOR and/or $VISUAL to always use your favourite editor in ~/.bashrc (make sure it is sourced from ~/.bash_profile) when using scripts or programs that invoke an editor - visudo and crontab -e for example.[/b]

Håkan

----------

## crystalattice

I've seen so many config files in the last few days that I'm confused.  Do you mean add the line "EDITOR=/bin/nano visudo" to the ~/.bashrc file?  I noticed there is no EDITOR line in the file already, so I don't want to screw anything up.

Also, I remember seeing in another config file (don't remember which one w/o looking through all my documentation) there was a line $EDITOR which reference nano.  Do I need to do anything to that line or file (once I find it again)?

Thanks for your help.

----------

## salam

strange. visudo never worked for me (and vi editor altogether) as the screen gets quite confused when i run vi. but though in sudo manual there is a note that the file should be edited only with visudo, i experienced no problems editing it with mc's internal editor or nano. i use a quite unsecure (but as i am only user of the machine it doesn't matter) but fast method for switching to root:

in sudoers:

```
user_login ALL=NOPASSWD: /bin/bash
```

and then sudo -i

----------

## gentoo_dude

 *Quote:*   

> Also, I remember seeing in another config file (don't remember which one w/o looking through all my documentation) there was a line $EDITOR which reference nano. Do I need to do anything to that line or file (once I find it again)? 

 

You mean /etc/rc.conf

In there you specify your editor.  Default is set to nano, set it to vi(m).  Probably you set it to emacs (hence the error message)

----------

## hw-tph

 *crystalattice wrote:*   

> I've seen so many config files in the last few days that I'm confused.  Do you mean add the line "EDITOR=/bin/nano visudo" to the ~/.bashrc file?

 

No. You can set environment variables for a specific command on the command line. $EDITOR is an environment variable that should point to your preferred non-graphical editor (another variable that does the same thing is $VISUAL) and by typing EDITOR="/usr/bin/nano" visudo you would run the visudo command with the editor set to nano. Like gentoo_dude said, you can set $EDITOR in /etc/rc.conf to have it applied at all times, but if you want to test an environment variable you can specify it on the command line like I explained above.

Think /etc/make.conf variables: You can override what you have got in the make.conf file by specifying the variable on the command line: USE="-X" emerge app-admin/whatever to compile something without X support, even though you usually want X support for most programs.

Håkan

----------

## crystalattice

Sweet, I finally got it working.  Thanks everyone for your help.

----------

## pjp

Moved from Other Things Gentoo

----------

