Results 1 to 10 of 10

Thread: messed up etc/sudoers

  1. #1
    Join Date
    Dec 2007
    Location
    howard, wi
    Beans
    2,460
    Distro
    Ubuntu 20.04 Focal Fossa

    Lightbulb messed up etc/sudoers

    running 14.04. i tired the recovery mode but could not install my backup get this message:
    sudo gedit /etc/sudoers
    >>> /etc/sudoers: syntax error near line 20 <<<
    >>> /etc/sudoers: syntax error near line 20 <<<
    sudo: parse error in /etc/sudoers near line 20
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin
    ray@nightmare:~$
    any ideas/tks
    quote:He that would live in peace & at ease, Must not speak all he knows,nor judge all he sees.'

  2. #2
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: messed up etc/sudoers

    save this somewhere, boot to recovery, and move it to /etc/sudoers
    Code:
    #                                                                                                                                                                                               
    # This file MUST be edited with the 'visudo' command as root.                                                                                                                                   
    #                                                                                                                                                                                               
    # Please consider adding local content in /etc/sudoers.d/ instead of                                                                                                                            
    # directly modifying this file.                                                                                                                                                                 
    #                                                                                                                                                                                               
    # See the man page for details on how to write a sudoers file.                                                                                                                                  
    #                                                                                                                                                                                               
    Defaults        env_reset                                                                                                                                                                       
    Defaults        mail_badpass
    Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root    ALL=(ALL:ALL) ALL
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    
    # Allow members of group sudo to execute any command
    %sudo   ALL=(ALL:ALL) ALL
    
    # See sudoers(5) for more information on "#include" directives:
    
    #includedir /etc/sudoers.d
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Dec 2007
    Location
    howard, wi
    Beans
    2,460
    Distro
    Ubuntu 20.04 Focal Fossa

    Lightbulb Re: messed up etc/sudoers

    sandy what would be the command to do that
    quote:He that would live in peace & at ease, Must not speak all he knows,nor judge all he sees.'

  4. #4
    Join Date
    Feb 2015
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: messed up etc/sudoers

    Quote Originally Posted by sandyd View Post
    save this somewhere, boot to recovery, and move it to /etc/sudoers
    ...
    Quote Originally Posted by rburkartjo View Post
    sandy what would be the command to do that
    Open gedit and copy/paste the contents in the code box by sandyd.

    Save to your desktop as "sudoers". Important - change the permissions to 0440 with the command,
    Code:
    chmod 0440 $HOME/Desktop/sudoers
    Note these permissions will allow the sudoers file to work correctly when you are finished in recovery mode.

    Now boot to a recovery mode screen, ensure the drive is mounted as read/write; you may need to choose the option to remount the root drive to do so.

    Once the root partition is writable choose the option to "drop to a root prompt". Then you can move the file to the /etc folder as root.
    The command,
    Code:
    mv /home/<your-username>/Desktop/sudoers /etc/sudoers
    Reminder, you are on a root prompt so "sudo" is not needed in this instance. Also change <your-username> in the command to that of your username on your install.

    The ownership of the file after doing so, should also change to that of root. If the file is not owned by root change it by the command,
    Code:
    chown root:root /etc/sudoers
    Reminder, you are on a root prompt so "sudo" is not needed in this instance.

    Once the file is moved and its permissions and ownership are correct, reboot back into your installation and test out if sudo is working correctly.
    Last edited by yetimon_64; September 23rd, 2015 at 07:30 PM. Reason: reword last sentence for clarity

  5. #5
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: messed up etc/sudoers

    And if all that works for you, please note carefully the first line of the file you just moved.

    You don't tell us how you messed up the file in the first place but if you had edited it with sudo visudo, which actually uses nano in Ubuntu, there is an automatic check of syntax before you save the file. Gedit, of course, does not do this for you so you can easily save a bad file and lock yourself out of using sudo if you're nor sure what you're doing.

  6. #6
    Join Date
    Dec 2007
    Location
    howard, wi
    Beans
    2,460
    Distro
    Ubuntu 20.04 Focal Fossa

    Lightbulb Re: messed up etc/sudoers

    getting this now how should i correct
    ray@nightmare:~$ !445
    sudo nautilus
    sudo: /etc/sudoers is owned by uid 1000, should be 0
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin
    ray@nightmare:~$
    appreciate all you help
    quote:He that would live in peace & at ease, Must not speak all he knows,nor judge all he sees.'

  7. #7
    Join Date
    Feb 2015
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: messed up etc/sudoers

    Quote Originally Posted by rburkartjo View Post
    ...
    sudo: /etc/sudoers is owned by uid 1000, should be 0
    ...
    From my previous post,
    The ownership of the file after doing so, should also change to that of root. If the file is not owned by root change it by the command,
    Code:
    chown root:root /etc/sudoers
    Bolded text is for emphasis.

    Ensure the file is owned by root and has 0440 permissions for it to work. Note that on the recovery panel when on a root prompt you don't need sudo to run that command above. You will need to use the recovery boot option again to change it.

    Edit: as per ajgreeny's post it is usual practice to use nano and sudo visudo to alter the sudoers file.
    However once the sudoers file is messed up "sudo visudo" itself may not work hence the use of gedit etc. above.
    I **think** ajgreeny is suggesting usage to avoid the problem in the first place. yeti.
    Last edited by yetimon_64; September 23rd, 2015 at 08:45 PM. Reason: noted ajgreeny's mention of "sudo visudo"

  8. #8
    Join Date
    Dec 2007
    Location
    howard, wi
    Beans
    2,460
    Distro
    Ubuntu 20.04 Focal Fossa

    Lightbulb Re: messed up etc/sudoers

    tks yeti. my new sudoers file was read only for some reason changed it to exe and ran the last command in recovery mode. all fixed. tks everyone
    quote:He that would live in peace & at ease, Must not speak all he knows,nor judge all he sees.'

  9. #9
    Join Date
    Feb 2015
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: messed up etc/sudoers

    Quote Originally Posted by rburkartjo View Post
    tks yeti. my new sudoers file was read only for some reason changed it to exe and ran the last command in recovery mode. all fixed. tks everyone
    The sudoers file is read only even for root on this Ubuntu system. Changing that to executable may not be a very good idea.

    Wait for further advice regarding that aspect of the sudoers file permissions. I am surprised that it is working if the permissions have been changed to executable as I thought the security of the system depends heavily on the sudoers file being correctly set up.

    I suspect the last command was used only and the permissions are actually non executable if it now works for you. If the permissions are actually 0440 then the file is NOT executable (nor should it be as far as I'm aware). Cheers, yeti.

  10. #10
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: messed up etc/sudoers

    Indeed I was talking about using sudo visudo to avoid the problem in the first place.

    For more info on sudoers and root-sudo see
    https://www.google.com/url?q=http://...x0bfLy7zcnT1DA
    https://www.google.com/url?q=https:/...Coqn9BKHykS34Q and Root-Sudo link in my signature.

    Finally, as you will see in that Root-Sudo link, never use sudo for any GUI application; that could be why you have ended up in this mess in the first place as it can cause an unintentional change of ownership and permissions of files which can then lock you out of your own home files and folders.

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
  •