Permission denied when trying to cd /usr/local/bin from terminal

Solution 1:

In versions of OS X or macOS previous to High Sierra (10.13), you could just type:

sudo chown -R $(whoami) /usr/local

This does not apply to macOS 10.13 or above, as System Integrity Protection will ensure the ownership of /usr/local cannot be changed.

Or if you want it specific to /usr/local/bin:

sudo chown -R $(whoami) /usr/local/bin

Also, your permission modes are off—ideally /usr/local/bin should be accessible by others too:

sudo chmod -R u=rwX,go=rX /usr/local/bin