I am new to the Mac philosophy, but I have been using Ubuntu since a while. Now I am using Mac at work, and I have to install a few programs, not apps, from source code distribution.

I did try to gunzip a folder in /usr/local/ but it says permission denied. Same result with sudo. The su command just freezes.

Is /Users/ a better place to go? I suppose I do not need permission to write in there, right?

Where should I install new software (from source code distribution) on a Mac?

  • What are the rights on /usr/local? Also, what are you trying to install? Homebrew might be the better approach than doing everything manually.
    – nohillside
    Apr 6, 2018 at 19:51
  • drwxr-xr-x 16 root wheel 544 Apr 6 18:53 local (I don't even know what wheel is).
    – Py-ser
    Apr 6, 2018 at 20:01
  • What do you get with sudo touch /usr/local/xyzzy?
    – nohillside
    Apr 6, 2018 at 20:16
  • 1
    What you are seeing is due to SIP (System Integrity Protection). As (indirectly) stated (hinted?) by others already /usr/local is where you can install your programs.
    – Allan
    Apr 6, 2018 at 20:23

2 Answers 2


To start we should define a few terms. An install from source code means that the software needs to be built before it can be executed.

So your first step is to find a place on your computer to perform the build. The best place for this is a directory in your home directory. I use a directory at ~/src/ to hold the packages. So, create this folder and unpack your source into here. Then you can build the software here.

When it comes to the executable files man hier will tell you that /usr/local is the place to install things not included in the OS. Homebrew, for example, will install into here. So executables should go into /usr/local/bin. Most software packages will have an install tool that will perform this step. Of course /usr/local/bin needs to be in your PATH variable.

This is identical to Ubuntu in almost every respect.

  • Thanks. Why I am not supposed to build the program in the same directory as where I want to store the executable? For memory purposes?
    – Py-ser
    Apr 9, 2018 at 15:26
  • 2
    You build in a different spot for reasons of neatness and purpose. Apr 9, 2018 at 20:30
  • @Pyser Also, for security reasons: on most systems, you’re going to store the executable in a place that needs root privileges to write. If you were to build the executable in that same place, you’d have to grant root privileges to the entire build process. That could be highly dangerous because the build process can usually execute arbitrary code, while installing is just copying files.
    – Synoli
    Jan 12, 2019 at 11:33

I did try to gunzip a folder in /usr/local/ but it says permission denied.

/usr/local/ is a protected directory in macOS. The observed behaviour in your case is due to System Integrity Protection. SIP does not allow even the root user or using sudo to chown /usr/local/.

As per man hier, /usr/local/ is the recommended directory for placing executables, libraries, etc. not included by the basic operating system. So it is where you should be installing your software (from source). The approach to take here is to create a directory under /usr/local and chown it to logged in user. This new directory can be used to install new software as per your liking.

/Users/ houses the users home directories, along with a Shared directory, shared between users. So, this is not the place to install new software, whether from source or not.

You can also refer to this nicely written answer discussing Standard for macOS filesystem.

  • 2
    I think the right terminology to explain why I can not use brew, is that we are talking of source code software.
    – Py-ser
    Apr 6, 2018 at 20:31
  • /usr/local indeed, what about my original post?
    – Py-ser
    Apr 6, 2018 at 20:35
  • Can I chown directly on /usr/local? This way I do not need to repeat the process for every other installed software...
    – Py-ser
    Apr 6, 2018 at 20:40
  • 1
    No! Your first paragraph is incorrect! /usr/local/ is not protected by SIP. From the link to SIP you posted: *Paths and apps that third-party apps and installers can continue to write to include.... /usr/local.
    – Allan
    Apr 9, 2018 at 13:19
  • 1
    I would remove it. The issue with sudo having the same results needs to be looked into - does he have rw permissions to /usr/local?
    – Allan
    Apr 9, 2018 at 13:37

You must log in to answer this question.

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