0

RHEL 5.10

When I do visudo I get this error:

chuck 75->visudo
visudo: /etc/sudoers: Permission denied
visudo: /etc/sudoers: Permission denied

Listing of sudo exe file and /etc/sudoers:

chuck 76->ls -l /etc/sudo*
-r--r----- 1 root root 3540 May  9 11:44 /etc/sudoers
-r--r----- 1 root root 3401 Aug 12  2014 /etc/sudoers.20140812

chuck 273->ls -l `which sudo`
-rwsr-xr-x 2 root root 182040 Mar  4  2014 /usr/bin/sudo

chuck 275->ls -l `which visudo`
-rwxr-xr-x 1 root root 98576 Mar  4  2014 /usr/sbin/visudo

As you can see my /etc/sudoers.20140812 backup file has the same permissions as the actual /etc/sudoers file. So I don't know what's up.

  • Just before this happened I changed my environment var in my .cshrc VISUAL to: setenv VISUAL /usr/bin/nano.
  • I've tried in the shell unset VISUAL but I still get "permission denied" error.
  • I've tried in the shell setenv VISUAL but that didn't work. When I did visudo I still get "permission denied on /etc/sudoers".
  • I also logged that shell window off and logged into a new one and still get "permission denied" when I do visudo.
  • I tried googling the answer and tried a few things but that didn't work.
  • Searching stackexchange didn't show any past questions either.

TRIED: Another thing I tried and the error message.

chuck 59->sudo chmod 0440 /etc/sudoers
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting

TRIED: Making an alias I called editsudo: alias editsudo 'sudo chmod 770 /etc/sudoers; sudo nedit /etc/sudoers; sudo chmod 0440 /etc/sudoers'

chuck 62->editsudo
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting
sudo: /etc/sudoers is mode 0640, should be 0440
sudo: no valid sudoers sources found, quitting
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Bulrush
  • 229

1 Answers1

2

Per man visudo, section "Diagnostics":

 /etc/sudoers.tmp: Permission denied
       You didn’t run visudo as root.

I see nothing in your post to indicate that you did run it as root.

Try sudo visudo.

Also it looks like you may be getting errors related to sudo itself. Can you sudo ls ~root successfully?


You may also want to review the man page, as:

 There is a hard-coded list of one or more editors that visudo will use
 set at compile-time that may be overridden via the editor sudoers Default
 variable.  This list defaults to /usr/local/bin/vi.  Normally, visudo
 does not honor the VISUAL or EDITOR environment variables unless they
 contain an editor in the aforementioned editors list.

The man page proceeds to describe ways to work around this, but you should be aware of the security implications of doing so. I would advice you to just learn vi since it is both ubiquitous and extremely powerful. (Start by running vimtutor; set aside half an hour for this.)

Wildcard
  • 36,499