Search code examples
ubuntuvisudonanosudoers

Visudo not working anymore, what can I do?


So... I accidentally opened up visudo by typing

vi visudo

and at the same time I also prefer nano so I just naturally pressed ctrl+x to exit, then didn't realize right away that I was in vi (yes i'm slow haha) and kept trying :P... anyway, I finally realized and haven't used vi in a while so I thought that :x would exit without saving, but I guess thats not the case and now when I try to visudo I get

-bash: /usr/sbin/visudo: cannot execute binary file

Any idea what I can do to fix this? The actual /etc/sudoers file is fine, i can open it and it looks normal, dont see anything wrong with it. So I guess its just the visudo file. Can I replace it or something?

Oh, and using Ubuntu 8.04 (Hardy)


Solution

  • visudo just a binary file with no built-in configurations, so you can safely replace it. Is included in the sudo package, which you can reinstall by typing:

    sudo apt-get install --reinstall sudo
    

    And if you're inclined to learn how to use the editor you stumbled onto, try typing

    vimtutor
    

    If all you care to know is how to exit vi / vim without breaking anything, the way to do is to type :q!