Where should I place local executables on macOS? [duplicate]
I often write system-wide scripts and I wonder where to place my executables on macOS.
On many Linux system, /usr/local/bin
(also /usr/local/sbin
) is usually empty and I place my executables in there.
But on macOS, /usr/local/bin
has already contained a lot of executables provided by such as Homebrew.
I understand /usr/local/bin
is the most proper directory to place executables locally installed and similar questions also are answered /usr/local/bin
, but I feel hesitant to contaminate by mixing my executables.
Is it good manner to place my executables in /usr/local/bin
in spite of many other executables existing?
In other way, I am wondering where is the second best directory to place my executables.
I think /opt/bin
is the second best at the moment because /opt/bin
seems to proper directory to place my executables by its purpose and /opt/bin
does not exist by default on macOS (empty assured).
Is there any idea or advice about my wondering?
similar questions (answered /usr/local/bin
is best):
- Where do you keep your own scripts on OSX?
- Where should I cp oc binary to on MacOS?
Homebrew doesn't directly install packages to the normal locations in /usr/local/
, it installs to its own directory (/usr/local/Cellar
by default) and then symlinks the files to /usr/local/bin
(or lib
, opt
, and so on).
You could follow this pattern and create your own directory in usr/local/
to store your executables, and then symlink them to /usr/local/bin
. This would let you keep all your own files organized in one place without needing to add a new directory to your $PATH.