Results 1 to 7 of 7

Thread: [SOLVED] How does visudo work?

  1. #1
    Join Date
    Dec 2007
    Location
    /home
    Beans
    483

    Smile [SOLVED] How does visudo work?

    I have edited /etc/sudoers in the past, using nano.
    However, the first line in the file says it must be edited with visudo.
    I would, but then, I don't really understand visudo.
    I tried man visudo, but that didn't help much.
    Even gvim is easier than that... at least it has buttons and menus!

    I would just like to know what visudo is using to edit /etc/sudoers. It kinda feels like vi (and even the name suggests vi).

    I'm no good with vi or vim either, but I do know files are edited with :e, and :wq is used to save and exit.

    Is that how it works with visudo?

    Or should I just stick to nano?

    Does it even matter which editor I use?
    After all, it says it MUST be edited with visudo...
    Don't eff with The Cult...

  2. #2
    Join Date
    Jul 2006
    Location
    Here
    Beans
    10,543

    Re: How does visudo work?

    visudo will use the editor you set as default, so for instance you can set yours to nano:

    sudo dpkg-reconfigure --config editor

    then when you> sudo visudo
    it will open in nano

    if you want to configure all your alternatives->
    sudo dpkg-reconfigure --all

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: How does visudo work?

    visudo is not exactly an editor. It spawns an editor, and checks the saved files for correctness.

    Justification : An incorrect sudoers file can be very painful, especially in Ubuntu, as you may not be able to edit it again. This is because you need to be root to edit it, and incorrect sudoers file will not let you gain root privileges. In most other distros, you can use root password(by default) to gain root privileges and repair your damaged sudoers file. It is tougher than that in Ubuntu.

    You can change which editor visudo spawns.
    Code:
    export EDITOR=nano
    sudo visudo
    This will open nano editor with visudo.

  4. #4
    Join Date
    Jan 2008
    Beans
    4,757

    Re: How does visudo work?

    Quote Originally Posted by bingoUV View Post
    You can change which editor visudo spawns.
    Code:
    export EDITOR=nano
    sudo visudo
    This will open nano editor with visudo.
    Wrong!

    It's
    Code:
    sudo -E visudo
    And personally, I keep the information stored in my .bashrc file
    Code:
    gedit ~/.bashrc
    Then type at the bottom:
    PHP Code:
    export EDITOR=nano
    alias visudo
    ='sudo -E visudo' 
    And then just type in "visudo" to start it up.

    Regards
    Iain

  5. #5
    Join Date
    Jan 2007
    Beans
    Hidden!

    Re: How does visudo work?

    Sorry, it could be some Ubuntu peculiarity. My RHEL 4 system's sudo does not even have -E option. And sudo visudo is working quite happily.

    Can you tell what is different? What does Ubuntu's sudo's -E option do?

    thanks

  6. #6
    Join Date
    Dec 2007
    Location
    /home
    Beans
    483

    Smile Re: How does visudo work?

    Thanks, all of you.
    I'll go set nano as default now (mine was, indeed, using vim).
    I just downloaded a huge PDF about vim. I hope I can make some sense of it. I feel a lot more comfortable with nano, but it never hurts to know a little more.

    Cheers!
    Don't eff with The Cult...

  7. #7
    Join Date
    Jan 2008
    Beans
    4,757

    Re: How does visudo work?

    Quote Originally Posted by bingoUV
    What does Ubuntu's sudo's -E option do?
    The -E option in Ubuntu keeps the users environment settings when the terminal switches to root.
    Last edited by ibuclaw; May 23rd, 2008 at 03:00 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •