I have been trying to set up some stuff for JS, but I need to use sudo. Every time I use sudo, I get this message.

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

I checked the /etc/sudoers file and found out that it is completely empty. How would I fix this?

  • Your first step would be to reinstall macOS without losing data. You can do this from macOS Recovery. Next, remember to always use sudo visudo to edit the shudders file so that you don't get errors with /etc/sudoers. If this works, let me know so that I can add it as the answer. – Todd May 13 '20 at 13:46
  • I really don't want to reinstall as that would probably take a long time and this is my Daily Driver. – GiraffeMan3125 May 13 '20 at 13:53
  • 1
    This would probably be the best option rather than further tampering with your sudoers file. If you install overnight, you should be fine. – Todd May 13 '20 at 13:55

I know that Todd said that it wasn't smart to do this, but I went to the opensource sudoers file from apple and copied that into my sudoers file, now sudo is working just fine!

  • I would mark this as the answer but I have to wait 2 days. – GiraffeMan3125 May 13 '20 at 14:31
  • It’s perfectly safe to do that; it’s the exact same file Apple uses. /etc/sudoers is just a text file “describing” who gets elevated permissions. +1 for finding a great solution. – Allan May 13 '20 at 14:38
  • How would this work in Catalina? – klanomath May 13 '20 at 15:16
  • 1
    What did you do before you copied the file to make sure you have the right to write the file? – nohillside May 13 '20 at 15:40
  • I looked at the get info page and added myself to the list of users who can read/write. – GiraffeMan3125 May 14 '20 at 16:51
  1. Boot to recovery mode
  2. Open Terminal (menubar > Utilities > Terminal)
  3. cd to your system data volume:

    cd /Volumes/Macintosh\ HD\ -\ Data/private/etc/

    (In system 10.14 and lower this is /Volumes/Macintosh\ HD/private/etc/)

  4. Download a default macOS sudoers file (e.g. from an online repository)

    curl -LJO https://gist.githubusercontent.com/keith/9061156/raw/1f056fa364640900eb42fcc9023d60a759c668c8/sudoers
  5. Check permissions:

    ls -l /Volumes/Macintosh\ HD/private/etc/sudoers
    -r--r-----  1 root  wheel  1283 May 13  2020 /private/etc/sudoers
  6. Boot to your main system volume
  7. Edit the sudoers file with sudo visudo and replace it with the content of the default Catalina sudoers file:

    # Sample /etc/sudoers file.
    # This file MUST be edited with the 'visudo' command as root.
    # See the sudoers man page for the details on how to write a sudoers file.
    # Override built-in defaults
    Defaults    env_reset
    Defaults    env_keep += "BLOCKSIZE"
    Defaults    env_keep += "COLORFGBG COLORTERM"
    Defaults    env_keep += "__CF_USER_TEXT_ENCODING"
    Defaults    env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
    Defaults    env_keep += "LINES COLUMNS"
    Defaults    env_keep += "LSCOLORS"
    Defaults    env_keep += "SSH_AUTH_SOCK"
    Defaults    env_keep += "TZ"
    Defaults    env_keep += "EDITOR VISUAL"
    Defaults    env_keep += "HOME MAIL"
    Defaults    lecture_file = "/etc/sudo_lecture"
    # User alias specification
    # User_Alias    FULLTIMERS = millert, mikef, dowdy
    # Runas alias specification
    # Runas_Alias   OP = root, operator
    # Host alias specification
    # Host_Alias    CUNETS =
    # Host_Alias    CSNETS =,,
    # Host_Alias    SERVERS = master, mail, www, ns
    # Host_Alias    CDROM = orion, perseus, hercules
    # Cmnd alias specification
    # Cmnd_Alias    PAGERS = /usr/bin/more, /usr/bin/pg, /usr/bin/less
    # User specification
    # root and users in group wheel can run anything on any machine as any user
    root        ALL = (ALL) ALL
    %admin      ALL = (ALL) ALL
    ## Read drop-in files from /private/etc/sudoers.d
    ## (the '#' here does not indicate a comment)
    #includedir /private/etc/sudoers.d


You can access this question & answer in Recovery Mode with Safari and copy the curl command.

  • a very thorough answer! – Seamus May 14 '20 at 7:16

You must log in to answer this question.

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