How to recover from "chown -R $USER /usr/"? I ran a 'chown' on everything under /usr to a non root user. Meant to run it for /usr/local/
Now I get the error below on opening terminal

login(89809,0x7fff7bac5960) malloc: *** error for object 0x7fc7cb500b40: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

[Process completed]
If you can't restore /usr/ from a backup, you could first start up in single user mode (by holding command-S on startup) and run chown -R root /usr/.

On my installation, all files under /usr/local/ were owned by either root or me, a few files under /usr/ were owned by _uucp, and all other files under /usr/ were owned by root:

$ sudo find /usr/local ! -user root ! -user $USER
$ sudo find /usr/!(local) ! -user root -print0|xargs -0 stat -f '%Su %N'
_uucp /usr/bin/cu
_uucp /usr/bin/uucp
_uucp /usr/bin/uuname
_uucp /usr/bin/uustat
_uucp /usr/bin/uux
_uucp /usr/sbin/uucico
_uucp /usr/sbin/uuxqt
_uucp /usr/share/uucp


This would change the owner of the uucp files:

sudo chown _uucp /usr/bin/{cu,uucp,uuname,uustat,uux} /usr/sbin/{uucico,uuxqt} /usr/share/uucp


/usr/local/ does not exist on a fresh installation of OS X. If you only used /usr/local/ with Homebrew, you might delete /usr/local/ and then reinstall Homebrew.

Alternatively, you could use Pacifist to copy the default /usr/ from an OS X installer downloaded from App Store. Doing an upgrade install of OS X from the recovery partition or upgrading to 10.9 might also restore the owners of some files.