There are variations, but also common themes and well-established guidelines.
root (/) hierarchy:
||Essential command binaries (e.g. ls, rm, chmod, perl, bash…)|
||Static files of the boot loader|
||Device files (e.g. console, null, tty, stdin/out/err)|
||Host-specific system configuration (e.g. hosts, fstab)|
||Essential shared libraries and kernel modules|
||Mount point for removeable media|
||Mount point for mounting a filesystem temporarily|
||Add-on application software packages|
||Essential system binaries (e.g. fdisk, fsck)|
||Data for services provided by this system|
||Variable data (e.g. mail)|
||Most user commands (usually installed by package manager)|
||Header files included by C programs|
||Local hierarchy (empty after main installation)|
||Non-vital system binaries|
||Local binaries (not installed by package manager - eg. compiled)|
||Host-specific system configuration for local binaries|
||Local game binaries|
||Local C header files|
||Local online manuals|
||Local system binaries|
||Local architecture-independent hierarchy|
||Local source code|
Where do I Install my Stuff?
By convention, software compiled and installed manually (not through a package manager, e.g apt, yum, pacman) is installed in
If you just need to extract a tarball and run directly (e.g. Firefox) then put it into
Why So Many Variations?
/sbin) were intended for programs that needed to be on a small
/partition before the larger
/usr, etc. partitions were mounted. These days, it mostly serves as a standard location for key programs like
/bin/sh, although the original intent may still be relevant for e.g. installations on small embedded devices.
/sbin, as distinct from
/bin, is for system management programs (not normally used by ordinary users) needed before
/usr/binis for distribution-managed normal user programs.
- There is a
/usr/sbinwith the same relationship to
/usr/local/binis for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into
/usr/binbecause future distribution upgrades may modify or delete them without warning.
/usr/local/sbin, as you can probably guess at this point, is to
In addition, there is also
/opt which is for monolithic non-distribution packages, although before they were properly integrated various distributions put Gnome and KDE there. Generally you should reserve it for large, poorly behaved third party packages such as Oracle.
man hier command to see what you have.
A diagram from here: