Directories with binary files in Linux

conventionsdirectory-structureexecutablefilesystems

I noticed that when I install new application there are a few possible directories where the resulting binary file will be placed.

You can install with packaging manager, compile with make, easy_install for Python etc.

My $PATH looks as follows:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Are there some conventions or rules that determine in which directory the resulting binary (or library) should be placed?

I noticed that when you compile the source code the result is often in /usr/local/bin/. Is this the rule?

Could you write the answer that explains the Unix philosophy (design and conventions decisions) according to binaries and why is it in this way (why not to use only one directory for all binaries)

Best Answer

There is no hard and fast rule but each distribution has its own logic behind putting things where they do. Generally, /bin is used for system binaries, /usr/bin for default applications that comes with the distribution and /usr/local/bin for things that are installed outside of the normal distribution. You can add a X11 to any of those for X11 binaries – /usr/X11/bin and /usr/local/X11/bin are quite common. Some software will install in /opt as well.

This article has a more in depth explanation for things in /. And of course, wikipedia has a page.