0

I am currently on macOS Big Sur 11.4, and I have noticed that my /opt directory is empty.

I opened the Terminal application and typed cd /opt. I then typed ls, but it did not show any files or directories.

This left me wonder whether the /opt directory is supposed to have certain directories and/or files or is supposed to be empty.

3
  • Probably a better question for ask different
    – jesse_b
    Jun 29, 2021 at 16:06
  • What have you searched for or researched to try to find he answer on your own? There are many documents on the web regarding Unix-style directory structures and layouts.
    – C. M.
    Jun 29, 2021 at 17:59
  • You are trying to solve a problem which does not exist - I am voting to close this question.
    – Panki
    Jun 29, 2021 at 18:07

1 Answer 1

0

It's empty by default. /opt is for add-on software packages. It is by definition, things that don't come with the OS.

Strictly speaking, whenever you've used /usr/local, according to a strict reading of the filesystem hierarchy standard, that probably should have gone in /opt instead. Comparatively, /usr/local is for "local data, specific to this host".

For some historical context, when NFS was highly popular, some organizations would have / and/or /usr mounted via NFS so they could have a consistent set of software installed for the entire org. /usr/local then would be mounted from the local (i.e., physically attached) storage of that machine. It was for things specific to that machine that did not apply to every other machine in the org.

If you feel the distinction between /opt and /usr/local is very subtle, you're not alone.

Since macOS started shipping with SIP (System Integrity Protection), /usr is read-only on new systems and you can't even create /usr/local (maybe this has changed, but IIRC this was the case at least for first release with SIP). Systems upgrading from an earlier version of macOS that did have /usr/local could still write to it.

If you have /usr/local, feel free to use it for whatever you want. If you're an application developer, don't count on being able to write to /usr/local on macOS. But regardless, on any Unix (or Unix-like) system, prefer /opt over /usr/local.

You must log in to answer this question.

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