What are binaries
Binary files hold compiled code (machine code) that the computer can run. They are also called executables. Linux keeps them in a few standard folders:
/bin/sbin/lib/opt
/bin
/bin has the programs that every user can run. It also has the basic commands needed in single-user (recovery) mode, such as cat, cp, ls and mv.
On modern distributions /bin is often a link to /usr/bin.
Other bin folders
Many other folders have their own bin subfolders. A user named Amy can keep her programs in /home/amy/bin. Some software installed from source goes to /opt. A Samba install can store its programs in /opt/samba/bin. Programs you build and install yourself usually go to /usr/local/bin.
/sbin
/sbin has system programs for administration. They normally need root rights. Examples: fsck, init, ifconfig, reboot and shutdown.
/lib
/lib has the shared libraries used by the programs in /bin and /sbin. It also holds kernel modules. The file names look like ld* or lib*.so.*, for example ld-linux.so.2.
Example listing:
ls /lib/libc*
/lib/modules
Holds the kernel modules, with one folder for each installed kernel (for example /lib/modules/5.15.0-91-generic). Modules add support for hardware without building a new kernel.
/lib32 and /lib64
On 64-bit systems the libraries for 64-bit programs go in /lib64, and those for 32-bit compatibility go in /lib32.
/opt
opt means optional. It stores add-on software packages, often from vendors outside the distribution repository. Each package gets its own folder, such as /opt/google/chrome. Some systems keep it empty.
Quick recap
| Folder | Holds |
|---|---|
/bin | Basic commands for all users |
/sbin | System administration commands |
/lib | Shared libraries and kernel modules |
/opt | Optional add-on software |
Use which command to see where a command lives.