I copied a file named class-dump to my /usr/bin folder, then neither Terminal.app nor iTerm2 work properly on my MacBook. There is something wrong with the sudo command.

Here is what I did based on some online searching:

sudo: effective uid is not 0, is sudo installed setuid root?
type sudo
sudo is hashed (/usr/bin/sudo)
ls -@@eil /usr/bin/sudo
1485457 -rwxrwxrwx  1 root  wheel  168448  7  9  2016 /usr/bin/sudo
md5 /usr/bin/sudo
MD5 (/usr/bin/sudo) = 7d986f7707c0f11264989cd7105ea80d

Does anyone know how I can make sudo work again?

  • 1
    Have you run chmod on /usr, /usr/bin or /usr/bin/sudo before? The permissions look very wrong - here's what I get from ls -@@eil: 101580151 -r-s--x--x 1 root wheel 360K 14 Sep 01:56 /usr/bin/sudo* – John N Jan 16 '17 at 8:31
  • Do you have a Recovery Partition on your system? With sudo not working you'll need to boot into it to chmod the command back into a sane state – nohillside Jan 16 '17 at 8:34
  • Yes I have run sudo chmod 777 /usr/bin/class-dump to give class-dump.app more power. As for ls -@@eil, I don't know what the result is meant for. – Jeremy Jan 16 '17 at 8:54
  • Does the Recoverry Partition mean using the disk utility? I have tried the emergency function, but nothing happened. – Jeremy Jan 16 '17 at 8:59
  • Boot to Recovery Mode(cmdR)/Internet Recovery Mode (altcmdR).

  • Get the name of your main system volume: df
    Usually it's the "Mounted on"- name of the device disk0s2 (e.g Macintosh HD) - simply check the sizes.

  • Enter chmod 4511 /Volumes/Name_Of_Sys_Vol/usr/bin/sudo

    Replace Name_Of_Sys_Vol by the volume name found in the previous command. If the name contains spaces, escape them with \. Example:

    chmod 4511 /Volumes/Macintosh\ HD/usr/bin/sudo
  • Check with ls -l /Volumes/Name_Of_Sys_Vol/usr/bin/sudo which should yield:

    -r-s--x--x  1 root  wheel  168448  7  9  2016 /Volumes/Name_Of_Sys_Vol/usr/bin/sudo

In Sierra with SIP enabled you wouldn't have been able to modify the permissions of sudo to 777. Therefore I assume Sierra isn't installed or SIP is disabled.

If Sierra is installed and SIP is enabled you have to disable it before applying changes to sudo..

  • It works! Now the sudo command can work correctly. Thanks! – Jeremy Jan 17 '17 at 1:23

You must log in to answer this question.

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