Linux Directory Structure Explained with Examples

L

Linux目录结构说明

/bin – User Binaries

存放二进制可执行文件(ls, cat, mkdir, ps, ls, ping, grep, cp等),在单用户模式下需要使用的常见linux命令位于此目录下。

Contains binary executables.
Common linux commands you need to use in single-user modes are located under this directory.
Commands used by all the users of the system are located here.
For example: ps, ls, ping, grep, cp.

/etc – Configuration Files

存放系统管理和配置文件

Contains configuration files required by all programs.
This also contains startup and shutdown shell scripts used to start/stop individual programs.
For example: /etc/resolv.conf, /etc/logrotate.conf

/home – Home Directories

存放所有用户文件的根目录,是用户主目录的基点,比如用户user的主目录就是/home/user,可以用~user表示

Home directories for all users to store their personal files.
For example: /home/john, /home/nikita

/usr – Unix System Resource

用于存放系统应用程序,比较重要的目录/usr/local 本地系统管理员软件安装目录(安装系统级的应用)。这是最庞大的目录,要用到的应用程序和文件几乎都在这个目录。

Contains binaries, libraries, documentation, and source-code for second level programs.

Sub-Directory Examples:

/usr/x11r6 存放window的目录

/usr/bin 众多的应用程序

/usr/sbin 超级用户的一些管理程序

/usr/doc linux文档

/usr/include linux下开发和编译应用程序所需要的头文件

/usr/lib 常用的动态链接库和软件包的配置文件

/usr/man 帮助文档

/usr/src 源代码,linux内核的源代码就放在/usr/src/linux里

/usr/local/bin 本地增加的命令

/usr/local/lib 本地增加的库

/usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
/usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
/usr/lib contains libraries for /usr/bin and /usr/sbin
/usr/local contains users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

/opt – Optional add-on Applications

额外安装的可选应用程序包所放置的位置。一般情况下,我们可以把tomcat等都安装到这里。

opt stands for optional.
Contains add-on applications from individual vendors.
add-on applications should be installed under either /opt/ or /opt/ sub-directory.

/proc – Process Information

虚拟文件系统目录,是系统内存的映射。可直接访问这个目录来获取系统信息。

Contains information about system process.
This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory contains information about the process with that particular pid.
This is a virtual filesystem with text information about system resources. For example: /proc/uptime

/root – Root

超级用户(系统管理员)的主目录(特权阶级^o^)

Every single file and directory starts from the root directory.
Only root user has write privilege under this directory.
Please note that /root is root user’s home directory, which is not same as /.

/sbin – System Binaries

存放二进制可执行文件,只有root才能访问。这里存放的是系统管理员使用的系统级别的管理命令和程序。如ifconfig等。

Just like /bin, /sbin also contains binary executables.
But, the linux commands located under this directory are used typically by system aministrator, for system maintenance purpose.
For example: iptables, reboot, fdisk, ifconfig, swapon.

/dev – Device Files

用于存放设备文件。

Contains device files.
These include terminal devices, USB, or any device attached to the system.
For example: /dev/tty1, /dev/usbmon0

/mnt – Mount Directory

系统管理员安装临时文件系统的安装点,系统提供这个目录是让用户临时挂载其他的文件系统。

Temporary mount directory where sysadmins can mount filesystems.

/boot – Boot Loader Files

存放用于系统引导时使用的各种文件

Contains boot loader related files.
Kernel initrd, vmlinux, grub files are located under /boot
For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

/lib – System Libraries

存放跟文件系统中的程序运行所需要的共享库及内核模块。共享库又叫动态链接共享库,作用类似windows里的.dll文件,存放了根文件系统程序运行所需的共享文件。

Contains library files that supports the binaries located under /bin and /sbin
Library filenames are either ld* or lib.so.
For example: ld-2.11.1.so, libncurses.so.5.7

/tmp – Temporary Files

用于存放各种临时文件,是公用的临时文件存储点。

Directory that contains temporary files created by system and users.
Files under this directory are deleted when system is rebooted.

/var – Variable Files

用于存放运行时需要改变数据的文件,也是某些大文件的溢出区,比方说各种服务的日志文件 (系统启动日志等)。

var stands for variable files.
Content of the files that are expected to grow can be found under this directory.
This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);

/media – Removable Media Devices

可移动媒体设备的临时挂载目录。

Temporary mount directory for removable devices.
For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

/srv – Service Data

服务相关数据,包含服务器特定服务的相关数据。

srv stands for service.
Contains server specific services related data.
For example, /srv/cvs contains CVS related data.

/lost+found

这个目录平时是空的,系统非正常关机而留下“无家可归”的文件(windows下叫xxx.chk)通常存放在这里。

On Linux, the fsck command—short for “file system check”—examines your file systems for errors. fsck may find bits of “orphaned” or corrupted files in the file system. If it does, fsck removes those corrupted bits of data from the file system and places them in the lost+found folder.

About the author

Haosen Yu
By Haosen Yu

Haosen Yu

Get in touch

School of Electronics and Computer Science
University of Southampton
Southampton
SO17 1BJ
United Kingdom

Visitor Map


This page was last updated in 2024.
HTML validated with no errors.
Image Hosting: Aliyun OSS.
Please report concerns to the webmaster.

error: Content is protected !!