I made another admin account in my MacOS Monterey for my programming job. Then I had to change ownership of Homebrew directories to make it work.

sudo chown -R $(whoami) /usr/local/Homebrew/ /usr/local/var/homebrew /Library/Homebrew/ /usr/local/Cellar

When I came back to my main account, Homebrew doesn't work. so I decide to to delete the new account and change the ownership of directories back to my main account.

the problem starts when I ran the following command and I need to revert it back.

sudo chown -R $(whoami) /usr

after that sudo command doesn't work and shows following exception:

➜  ~ sudo vi x.t
sudo: /usr/local/bin/sudo must be owned by uid 0 and have the setuid bit set

here is the sudo permissions:

➜  ~ ls -l /usr/bin/sudo                 
-r-s--x--x  1 root  wheel  1246544  8 Dec 10:39 /usr/bin/sudo

I activated the root account to change permissions but it doesn't work. I also reinstalled the OS but there is no success. I tried to replace /usr directory with my friend /usr directory with the same OS but the directory and it's file are read only. I could not change things in Recovery Mode Terminal.

Please advice.

2 Answers 2


You messed up the ownership of /usr/local/bin/sudo, but /usr/bin/sudo is ok so you can use that to repair the other:

/usr/bin/sudo root /usr/local/bin/sudo

There are probably other problems, since you changed ownership of all of /usr instead of just the relevant directories. But be specific and careful when making repairs -- it seems like you're in a vicious cycle where each attempt to repair a problem just creates even bigger problems (and if you'd succeeded in replacing /usr, that would have created bigger problems). Do not try to fix things by hitting them with bigger and bigger hammers, that just makes bigger and bigger messes.

P.s. Relevant xkcd: https://xkcd.com/349/


Basically Homebrew is designed for a one user machine.

It needs its directory (On Intel /usr/local/bin) writeable by that user and the install instructions do that by making that user own the directory. Now under Unix you can't have two users owning the same directory.

The normal Unix way (as done for 40 years) for installing software to be used by multiple users is to install into a directory owned by root or a special user for installing. Thus all users can run the executables but you have to have sudo rights to update things. (My view is that you update much less often than run the executables so this is not a problem)

For Macs there are several other package managers that stick to the normal Unix way and I would use one of them e.g. MacPorts, conda, fink, nix

You must log in to answer this question.

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