Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm migrating to OSX and need to figure out when to keep my scripts and libraries. I have code in Perl and Python, and libraries I've written in both languages. I am the only user of this machine so I imagine the difference between, ~/bin/ and /usr/local/bin/ is less clear than on a multi-user machine.

I'm not sure what the correct layout of such files is under Unix (even after poking around, e.g., here) and even less so under OSX's nonstandard arrangement.

Where should I put the scripts that I actually run? In ~/bin/? In /usr/local/bin/? Should I segregate the Python and Perl in, say, ~/bin/python/ and ~/bin/perl/?

And (harder I think) where should I put the libraries? In ~/lib/? In ~/lib/python/ and lib/perl/? Or somewhere in ~/Library/?

share|improve this question
up vote 0 down vote accepted

If you want to maintain compatibility with other Unix/Linux systems, you should use /usr/local/bin and /usr/local/lib, even though you're the only user on the machine. The Filesystem Hierarchy Standard indicates that the /usr/local hierarchy:

is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

Technically, if the programs are only for your own use, you could use ~/bin, ~/lib, etc., but I usually reserve those directories for when I'm a non-admin user on a shared machine (on my web host, for example).

As far as segregating based on language, the binaries should all be in /usr/local/bin, but libraries can be in /usr/local/lib/perl5, /usr/local/lib/python3.3, etc.

share|improve this answer

You must log in to answer this question.

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