1

I have a usr/bin/sudo problem on my Mac (El Capitan).

It started when I ran into a permissions problem installing from NPM and followed their directions here: https://docs.npmjs.com/getting-started/fixing-npm-permissions

I found out that was a really stupid thing I did here:
/usr/bin/sudo must be owned by uid 0 and have the setuid bit set version .ubantu14.04 LTS

I open up my terminal and get:

malloc: * error for object 0x7fff38418900: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug [Process was terminated by signal 6]

This essentially kills my terminal and therefore my work.

I Command-S while rebooting to start in single user mode. I run

fsck -fy

and my hard drive appears to be OK. I then got to: http://osxdaily.com/2015/11/04/verify-repair-permissions-mac-os-x/ which tells me to fix the permissions as I have El Capitan and therefore cannot use Disk Utility for this. I run:

sudo /usr/linexec/repair_packages --verify -standard-pkgs /

The terminal spits back:

sudo: effective uid is not 0, is sudo installed setuid root?

I dig deeper: https://apple.stackexchange.com/questions/194854/sudo-effective-uid-is-not-0-is-sudo-installed-setuid-root/194856

$ type sudo
sudo is hashed (/usr/bin/sudo) 

$ ls -@@eil /usr/bin/sudo
-r-s--x--x 1 501 wheel 168448 Dec 2 2015 /usr/bin/sudo

$ md5 /usr/bin/sudo
MD5 (/usr/bin/sudo) = 7d986f7707c0f11264554cd4354ef80d

I then

$ /usr/bin/sudo mv /usr/local/bin/sudo /usr/local/bin/sudo-strange
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

I find a truly depressing answer here: https://askubuntu.com/questions/452860/usr-bin-sudo-must-be-owned-by-uid-0-and-have-the-setuid-bit-set . But I'm an optimist so I ignore the first answer and do what the second answer tells me to:

$ chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
chown: root: illegal group name

which tells root doesn't exist. But when I

$ whoami
root

So I'm at a dead end and I really don't want to take two days reinstalling EVERYTHING.

Any suggestions?

Community
  • 1
  • 1
James Fallon
  • 41
  • 1
  • 2
  • 7
  • I have the EXACT same problem as you but don't know how i got it. I had the malloc error too, and i solved that by updating to the latest version of macOS, and now the sound and terminal doesn't' work. To repair the disk permissions, try [Onyx](http://www.titanium.free.fr/onyx.html). It didn't work for me but it might work for you. [How to use it](http://stackoverflow.com/questions/22329005/mac-terminal-pointer-being-freed-was-not-allocated-error-when-opening-termin) –  Dec 17 '16 at 22:56

5 Answers5

1

The problem is that you probably change permission to directoty /usr/bin. To resolve that :

Fisrt be sure that root is owner of this directory /usr/bin :

Chown root:root /usr/bin

and change permission for this directory /usr/bin/sudo:

chmod u+s /usr/bin/sudo
0

It's because of Permission issue

$ su
Password: <type your root password>

Switch to root user and run the command

# pkexec chmod a=rx,u+ws /usr/bin/sudo

Then check it by typing from the user

$sudo -l

It works fine for me.

NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
Keval Mangukiya
  • 2,243
  • 2
  • 11
  • 13
0

This happens when we mess up permission for sudo file

Enable the root user: https://www.hostmyapple.com/blog/how-to-enable-the-root-account-in-macos

Switch to root user:

$ su
Password: <type the root password set while enabling root user>

Change the permission:

chmod root:root /usr/local/bin/sudo

(if you remember the file where you changed the permission, use that file instead of usr/local/bin/sudo)

This should solve it. If this still doesn't help, try deleting /usr/local/bin/sudo from root user.

0

use /usr/bin/sudo to execute command

/usr/bin/sudo chmod 511 /usr/local/bin/sudo
/usr/bin/sudo chown root:wheel /usr/local/bin/sudo

/usr/bin/sudo chown -R root:wheel /usr/local/libexec/sudo/
/usr/bin/sudo chmod -R 511 /usr/local/libexec/sudo/
WensonSmith
  • 185
  • 1
  • 1
  • 6
-2

I faced the same issue with macOS sierra. After trying few other things and failing each time, I noticed that I had a pending update for my OS, installed the update and everything went back to normal.

Nitesh
  • 1
  • 1