In most cases, the sudo
command displays the error unable to initialize PAM: No such file or directory
mostly appears when the pluggable authentication module file /etc/pam.d/sudo
has been edited with a typo or an incorrect PAM module.
If you have an older Mac, you can boot into single-user mode
, which allows you to access the command line mode of macOS directly, bypassing the UI.
-
Press and hold down the
COMMAND + S
keys until you see commands being executed in the Terminal. -
Open the
sudo
file withvi /Volumes/Macintosh\ - Data/etc/pam.d/
, fix what's wrong, save and close the file by switching fromINSERT
to theCOMMAND
mode with theESC
key, type:wq!
, and hitenter
.