8

In Linux we have /home/<user>/bin to put special binaries that only that user will execute, and also, the user doesn't need root permissions to put them there.

Do we have any similar thing OS X?

We have /usr/bin, but as a regular user we need root permissions to place a file there, and I'm not looking for a folder like that.

slhck
  • 235,242

2 Answers2

11

In Linux we have /home/<user>/bin to put special binaries that only that user will execute

This is not standard Linux. Under Linux, or Unix-like systems such as OS X, you can have a directory for executables anywhere you want, as long as:

  • it is in your $PATH
  • the partition it's on allows execution of files (see the noexec option for mounting file systems)

Simply create /Users/your-username/bin and add it to PATH – you're done. See: What are PATH and other environment variables, and how can I set or use them?

You can also create /usr/local/bin, then run sudo chown -R /usr/local to have it owned by your account. This directory is not used by default in OS X, and the Filesystem Hierarchy Standard recommends it as a place to put software installed by the administrator. If you're the only admin user of that machine, that works pretty well.

slhck
  • 235,242
0

XDG specs go for using "$HOME/.local/bin" on desktop systems

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

https://specifications.freedesktop.org/basedir-spec/latest/

Server systems (command line only) go by /home/user/bin, but often you would use share your bins on servers, so put it to /user/local/bin for all users.

Anyway, I don't know systems which do set these directories by default tpo their path. I'd just say enforcing users to use $HOME/bin on their desktop systems is ugly and not nyce and outs you as macOS user ;)