6

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.

9

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.

2
  • I follow your first advice, thanks @slhck for the tip. I personally don't like the idea to put custom files into global folders instead of puting in user folders, this is because I think you're creating a bad habit. No matter you're the only one that uses the machine, when you go to server you will replicate this bad habit automatically. My two cents. – alexserver Sep 18 '13 at 19:22
  • It depends on the use case. The Filesystem Hierarchy Standard is a standard for a reason – you don't create bad habits if you follow it. It's actually the other way 'round. That being said, if you share your system with multiple users and don't want to share binaries with those users, of course your home directory is where you want to put them. – slhck Sep 18 '13 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.