π Linux Subdirectory <strong><span>/usr</span></strong>
Directory Detailed Explanation
π I. Overview
<span><span>/usr</span></span>
is one of the most important directories in the Linux file system, which stands for “Unix System Resources”. It is used to store user programs, system tools, library files, documentation, shared resources, etc.. Originally designed as a read-only directory, it can be shared across multiple systems via network or local mounts.
π II. Structure and Content of the /usr Directory
/usr/βββ bin # Binary files for user commands (e.g., common commands like ls, cp, grep, etc.)βββ sbin # Binary files for system administrators (e.g., ifconfig, iptables, etc.)βββ lib # Library files and kernel modules (for the current architecture)βββ lib64 # Library files for 64-bit systems (used by some systems)βββ include # Header files for C/C++ programming (e.g., standard library headers)βββ local # Locally installed software and resources (distinct from system package management)βββ share # Architecture-independent shared data files (e.g., documentation, fonts, themes)βββ src # Optional directory for storing system source codeβββ man # Manual page filesβββ games # Games and entertainment software (now rarely used)βββ tmp # Temporary file directory for program use
π III. Detailed Explanation of Common Subdirectories
π 3.1 /usr/bin
-
Stores binary executable files that users can use.
-
Contains a large number of user commands provided by the system:
<span><span>ls</span></span>
,<span><span>cp</span></span>
,<span><span>grep</span></span>
,<span><span>bash</span></span>
, etc. -
Users can execute without special permissions.
π 3.2 /usr/sbin
-
Stores binary files used by system administrators.
-
Includes:
<span><span>ifconfig</span></span>
,<span><span>iptables</span></span>
,<span><span>useradd</span></span>
,<span><span>visudo</span></span>
, etc. -
Ordinary users typically cannot access or execute, only administrators or those using
<span><span>sudo</span></span>
can run.
π 3.3 /usr/lib and /usr/lib64
-
Stores library files and kernel modules.
-
<span><span>/usr/lib</span></span>
is for 32-bit libraries or common libraries,<span><span>/usr/lib64</span></span>
is for libraries for 64-bit systems. -
Includes:
<span><span>libc.so</span></span>
,<span><span>libm.so</span></span>
, etc., standard C libraries and third-party libraries.
π 3.4 /usr/include
-
Used to store header files for C and C++ languages.
-
Developers use
<span><span>#include</span></span>
to include file paths when writing programs. -
Includes:
<span><span>stdio.h</span></span>
,<span><span>stdlib.h</span></span>
,<span><span>unistd.h</span></span>
, etc.
π 3.5 /usr/local
-
Used for installing locally compiled or third-party programs.
-
Not controlled by system package managers (like
<span><span>apt</span></span>
,<span><span>yum</span></span>
), users can modify freely. -
The directory structure is similar to
<span><span>/usr</span></span>
, but specifically for manually installed software:
/usr/local/βββ bin # User binary filesβββ sbin # Administrator binary filesβββ lib # Library filesβββ include # Header filesβββ share # Architecture-independent dataβββ src # Source code
π 3.6 /usr/share
-
Stores architecture-independent shared data files.
-
Includes: manuals, fonts, icons, internationalization resources, documentation, etc.
-
For detailed content, refer to:
<span><span>/usr/share Detailed Explanation</span></span>
.
π 3.7 /usr/src
-
Stores Linux kernel source code and third-party source code.
-
Commonly found in environments for developing or compiling custom kernels.
-
Example:
<span><span>/usr/src/linux-headers-5.10.0-13/</span></span>
.
π 3.8 /usr/man or /usr/share/man
-
Stores manual page files, divided into multiple sections.
-
Access method:
<span><span>man <command></span></span>
, such as<span><span>man ls</span></span>
.
π 3.9 /usr/games
-
Traditionally used to store binary files for games or entertainment software.
-
Rarely used in modern systems, usually an empty directory.
π 3.10 /usr/tmp
-
A optional temporary directory, similar to
<span><span>/tmp</span></span>
. -
Almost unused in modern systems, usually an empty directory.
π IV. Differences Between /usr and Other Directories
Directory | Purpose | Can be mounted as read-only |
---|---|---|
<span><span>/bin</span></span> |
Essential user commands, used for system boot and recovery. | β |
<span><span>/sbin</span></span> |
Essential administrator commands, used for system maintenance. | β |
<span><span>/lib</span></span> |
Essential library files, used during system boot. | β |
<span><span>/usr</span></span> |
A large collection of standard user programs and resources. | β (usually read-only) |
<span><span>/usr/local</span></span> |
Locally installed applications and resources. | β (usually read-only) |
<span><span>/var</span></span> |
Variable data files (logs, caches, lock files, etc.). | β |
π οΈ V. Usage Examples
5.1 View <span><strong><span>/usr/bin</span></strong></span>
all programs
ls /usr/bin
5.2 View <span><strong><span>/usr/lib</span></strong></span>
library files
ls /usr/lib | grep lib
5.3 Install custom software to <span><strong><span>/usr/local</span></strong></span>
./configure --prefix=/usr/localmake
sudo make install
5.4 View manual page
man ls
β VI. Summary
-
<span><span>/usr</span></span>
is one of the most important directories in the Linux system, containing user programs, library files, shared resources, etc. -
Distinguished from
<span><span>/bin</span></span>
,<span><span>/sbin</span></span>
,<span><span>/lib</span></span>
and other core directories,<span><span>/usr</span></span>
data can be mounted as a separate partition or read-only directory. -
It is recommended to place locally custom-installed software in the
<span><span>/usr/local</span></span>
directory to avoid conflicts with the system package manager.