I was playing around with the pam.d file in nano and for some reason along the way I lost root access. Whenever I try to use the sudo command, I get an error like this:

[redacted]@[redacted] ~ % sudo sh
sudo: unable to initialize PAM: No such file or directory

When I try to go into single-user mode, or use sudo - I get the same error.

This is what the pam.d file looks like. I can't edit it back.

# sudo: auth account password session
auth       sufficient     /usr/local/Cellar/pam-u2f/1.0.4/lib/pam/pam_u2f.so
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so

When I try to save, I get an error message saying [ Error writing sudo: Permission denied].

I'm on a MacBook Air 2017 running 10.15.1. How do I get back root access? Any help would be appreciated. Thanks!

  • How are you entering single-user mode? Cmd+S or Cmd+V?
    – Michael
    Aug 10, 2020 at 16:40

1 Answer 1


This probably won't help you at this point, but for future reference, an easy way to fix it would be to set a root password and then type su to switch to the root user.

See: https://support.apple.com/en-us/HT204012

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.