3

My server crashed and I had to restart it from the power button. However once I restarted it i can no longer run sudo. When I try I get

>>> /etc/sudoers: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

I then ran

pkexec visudo

which returns

��������������������������ï¿ï¿½u�fZc�f�<��^F� ��^H���g���&^R& k^N�^[N)��@{^H�Ƽ^P��8^^����0,(iȼ4_ï¿ï¿½ï¿½d$9��y^YW�ż^O}�f��ȼ0v��lE"G^A^@^Y1���$

So how do I recreate my sudoers file, or am I boned?

1 Answer 1

3

Here's the default /etc/sudoers file in Trusty:

#
# 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

You can replace your corrupted /etc/sudoers file with this one using a Live DVD:

  1. Boot from a Live DVD
  2. Open Terminal with Ctrl+Alt+T
  3. Run lsblk to see to which block device your root partition on the drive is mapped to
  4. Mount the root partition on the drive: sudo mount /dev/<partition_block_device> /mnt (where <partition_block_device> = root partition's block device)
  5. Run sudo gedit /mnt/etc/sudoers
  6. Paste in the content of the clean /etc/sudoers file
  7. Save
  8. Quit
  9. Run exit
  10. Reboot
4
  • Can I just use pkexec visudo to paste in the default text?
    – Dowlers
    Apr 23, 2015 at 7:16
  • @Dowlers If you are able to do, sure
    – kos
    Apr 23, 2015 at 7:18
  • That worked thank you very much. Unfortunately other files are displaying the same corruption so I'll have to do a complete reinstall anyway.
    – Dowlers
    Apr 27, 2015 at 15:05
  • Does it remove the iptables contents, ip address configurations etc ? May 24, 2018 at 7:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .