I write binaries every once in a while and I always struggle with where to store them. I write them often enough that I need to answer the question about where to put them and infrequently enough that I can never remember what I decided last time I faced the question. So, I wrote this article, and my rationale, to help solidify the choice for my future self.
Before I get to my choice, here are all the possibilities I considered. This is a list of some of the most common locations you might store a binary under MacOS (or Linux for that matter).
~/.local/bin
It’s gaining in popularity and is often considered the modern standard. It aligns with the XDG Base Directory Specification, which aims to clean up the home directory by consolidating configuration and data files into standard locations. Placing your binaries in ~/.local/bin
helps keep your home directory less cluttered.
If you create a command-line tool and share it with the audience on Hacker News the XDG Base Directory Specification you will often come up in the comments, especially if you don’t follow that standard. Lots of utilities continue to do their own thing.
It gets enough mention that I think it’s a standard worth following. Plus, having a standard is better than not.
~/bin
but I won’t be using itThis is a long-standing convention. It’s nice and clean and is suggested by a lot of guides. I don’t know that it’s a standard but it is certainly a tradition.
My personal preference is to use this location but I’m not for the reasons mentioned above. It’s easy to remember and it’s a well established standard but I’ve elected to use the XDG suggestion rather than stick to this tried and true location.
/usr/local/bin
might make senseOn many systems you must be root to access this directory. It’s a good choice if you are root and you are trying to install binaries for every user on this system. But, generally, if you are the only user on the system I’d suggest using one of the other options.
/usr/local/sbin
This is intended specifically for system management. The s
is said to stand for system. It should really be used for system management tasks and probably those specifically required by the operating system itself.
/opt/bin
is rare and non-standardThis one is relatively rare but is sometimes used by 3rd party packages.
~/go/bin
is okayThis is the Go convention. It’s where things will be installed if you run go install {thing}
. It’s probably a good choice for tools written in Go especially if they will be used by Go developers.
Written by Joel Dare on June 16, 2025.
Get battle-tested dev tips, terminal wizardry, and practical Mac hacks from a veteran engineer who speaks your language. Subscribe now and power up your toolkit—no fluff, just real code magic.
JoelDare.com © Dare Companies Dotcom LLC