Search code examples
macosunixterminalsudo

Why sudo does not work in a macOS terminal?


I asked this question on mac rumors but as it's pretty developer specific no one could help so wondered if any developers here would know. Sometime in the last couple of weeks something happened that completely broke my sudo command. Now everytime I try to sudo anything it just comes up with a blank line. Nothing I can type into Terminal (or iTerm) does anything and I need to close the window.

enter image description here

I've got backups but don't know what files would have been broken and don't just want to reset my Mac to an arbitrary point in time and loose other work. I mostly just use sudo to edit /private/etc/hosts file and somehow now it's letting me edit and save that without sudo so I thought it might be stuck in sudo somehow but I've reset everything I can think of and haven't changed any settings that I know of.

I tried creating a new admin user and sudoing from that but it's the same.

I've tried following advice on various forums but none of them are working and I'm getting to the point I'm probably doing more damage to my mac. Anyone got any ideas of how to fix it or any files I can drag across from my backup that might fix it?

I've tried:

which sudo

and it comes up with /usr/bin/sudo which seems to be a valid file path.


Solution

  • After following this link - https://macperformanceguide.com/blog/2017/20170328_1326-macOS-10_12_4-sudo-broken.html - I found the solution and the problem. AMPPS had edited the sudoers file to include some NOPASSWD line which apparently doesn't work in 10.12.4. Commenting out those lines works

    https://macperformanceguide.com/blog/2017/20170407_1157-macOS-10_12_4-sudo-broken-fix.html