The Filesystem Hierarchy Standard specifies where Linux distributions should place files.
bin directories contain executables intended to be used by any user, while sbin directories contain executables intended to be used only by the system administrator. sbin directories are normally only in root's $PATH.
/bin (and /sbin) contain programs that are needed early in the boot process, because /usr could be mounted on a separate partition (even though this is rare nowadasy).
/usr/bin (and /usr/sbin) contain programs that are provided by the distribution, and that are not in /bin or /sbin. On a typical system, a large majority of executables are in /usr/bin.
The /usr/local hierarchy is the realm of the administrator. The directories /lib, /bin, /sbin and /usr are normally reserved to the distribution, and generally contain only files provided by the system package manager. /usr/local (and in particular /usr/local/bin and /usr/local/sbin) are untouched by the package manager, so this is where the local administrator may place executables installed manually.
/usr/games may contain executables that are provided by the distribution and considered purely recreational. It's largely a historical survivance (a long time ago, /usr/games might be off-limits at certain times of the day, but this kind of practice — which was easy to work around anyway — has died down).
Other common executable locations on Linux system include:
/usr/X11R6/bin or /usr/bin/X11 for X programs. The practice of separating X programs from non-X programs has died down; nowadays they all live in /usr/bin.
/usr/bin/mh for executables of the MH email client, which manipulates emails through single-purpose shell commands (show to display a message, forw to forward a mail, …) Only MH users would put /usr/bin/mh in their $PATH.
/opt/bin, if it exists, would contain symbolic links to applications installed in /opt.
The rules for Linux are inspired by general guidelines followed by most unix systems, but each unix variant has its own quirks. For example:
- On *BSD,
/ and /usr contain only the core of the distribution: basic services and applications that are maintained directly by the distribution maintainers. Third-party programs (“packages” or “ports”) are installed in /usr/local, even if they are managed by a package manager. There is no commonly-accepted separate location for programs provided by the system administrator.
- Some unix systems have no
/bin directory, it's a symbolic link to /sbin or /usr/bin.
- Some systems may have extra directories containing optional package, each of which puts its own
bin directory in the $PATH.
- Some systems may have extra directories which may or may not be placed on the
$PATH depending on what the execution environment should be compatible with, for example /usr/bin/posix or /usr/xpg4/bin or /usr/xpg6/bin for compatibility with POSIX/Single Unix, or /usr/ucb for compatibility with legacy BSD systems.