mac won't start after "sudo chown -R $(whoami) $(brew --prefix)/*" command

Solution 1:

It sounds like you mistyped the command or had problems with your brew command, making the chown apply to not only /usr/local but rather / - i.e. the whole system. The command you have written is actually relatively dangerous, as you're relying on "brew --prefix" to output the right thing.

In this case your command changed the owner of system files, such as the /etc/sudoers file. This is why the system won't boot anymore.

The good news is that you should be able to boot the Mac in Recovery Mode by holding down Cmd and R while booting. From there you should be able to select that you want to reinstall macOS on your computer. This should allow you to overwrite those system files and ensure that the system is good to boot, while keeping your own files intact. If you have done any changes to the system files, you'll loose those ofcourse.