Linux basics-15day-Linux system directory structure

Linux system directory structure

1. Catalog introduction

When using a Linux system, you can use ls-l/ to find that there are many directories under /, and there are still many directories or files in these directories. The file system looks like a tree structure under Linux, so we can call the structure of the file system a tree structure.

The file system is used to organize and arrange file access. In Linux, we can view its structure through tools such as ls. In the Linux system, everything we see is a tree structure. For example, the operating system is installed in a file system, and it appears as a tree structure from/to the beginning. The top of the Linux file system is /, we call / the root of Linux, which is the file system of the Linux operating system. The entry of the Linux file system is /, all directories, files, and devices are under /, and / is the organizer of the Linux file system. Everything in a Linux system is a file.

File system Hierarchy Standard (file system directory standard) abbreviation, most Linux versions use this file organization form, similar to the file directory of the c drive in the Windows operating system, FHS uses a tree structure to organize files. FHS defines the purpose of each area in the system, the minimum required files and directories, and also provides exception handling and contradiction handling.

The FHS only defines what data should be placed under the three-level directory for the directory tree structure. They are:

( 1) /(root, root directory): related to booting the system;

( 2) /usr (unix softwar eresource): related to software installation/execution;

( 3) /var(variable): related to the system operation process.

2. Catalog Features

( 1) / (root) is the vertex of all directories.

( 2) The directory structure is like an upside-down tree.

( 3) Directory and disk partition are not related by default.

( 4) Different directories under /(root) may correspond to different partitions or disks.

( 5) All catalogs are organized according to certain categories and laws.

3. Catalog description

3.1/ directory

The root directory is the most important directory of the entire system, because not only all directories are derived from the root directory, but the root directory is also related to actions such as boot /restore/system repair. As the system needs specific boot software, core files, programs needed for booting, libraries and other file data when booting the system, if there is an error in the system, the root directory must also contain a program that can repair the file system. Because the root directory is so important, in terms of FHS requirements, it hopes that the root directory should not be placed in a very large partition, because the larger the partition, the more data will be placed, so that the partition where the root directory is located is possible There will be more opportunities for errors.

Every file and directory starts from the root.

3.2/bin directory

/bin is the directory where binary executable commands are stored. The commands under /bin can be used by root and general accounts, mainly: cat, chmod (modify permissions), chown, date, mv, mkdir, cp, bash, etc. instruction.

3.3/sbin directory

Used to store binary executable files, but the commands inside are only for system administrators and management systems (root users). For example: iptables (protection wall), ifconfig (check network card information), init (set startup level), etc.

3.4/boot directory

Mainly place the files used in the opening opportunity, including Linux core files, boot menu and configuration files required for booting, etc. The commonly used file name of the Linux kernel is: vmlinuz. If you are using the grub boot management program, the directory /boot/grub/ will also exist.

3.5/dev directory

Linux系统上,把所有的硬件用文件的形式存储。比较重要的文件有/dev/null,/dev/zero,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*等。

3.6/etc目录

yum/rpm安装的软件配置文件所在的目录,系统主要的配置文档几乎都放置在该目录内,例如人员的帐号密码、各种服务的启动文件等。该目录下的各文件属性是可以让一般使用者查阅的,但是只有root有权力修改。

3.7/home目录

普通用户家目录(homedirectory),用来存放普通用户的文件

3.8/lib目录

存放二进制库文件,库文件一般以.so|lib*|ld*。

3.9/media目录

media是媒体的英文,顾名思义,该/media底下放置的就是可移除的设备。包括软碟、光碟、DVD等装置都暂时挂载于此。常见的档名有:/media/floppy,/media/cdrom等。

3.10/mn目录

一般用来临时挂载临时存储设备的目录。

3.11/opt目录

一般是给第三方厂家开发的程序的安装目录。现在一般不用。

3.12/root目录

系统管理员(root)的家目录。如果进入单人维护模式而仅挂载根目录时,该目录就能够拥有root的家目录,所以我们会希望root的家目录与根目录放置在同一个分区中。

3.13/srv目录

srv可以视为service的缩写,是一些网路服务启动之后,这些服务所需要取用的资料目录。常见的服务例如WWW,FTP等。

3.14/tmp目录

临时文件存放的地方,由于该目录的权限为1777,所有用户对该目录都有可读可写可执行的权限,所以其他人也可以删除你的文件。

3.15/lost+found目录

该目录使用标准的ext2/ext3文件系统格式才会产生的一个目录,目的在于当文件系统发生错误时,将一些遗失的片段放置到该目录下。该目录通常会在分割槽的最顶层存在,例如你加装一个硬盘于/disk中,那在该系统下就会自动产生一个这样的目录/disk/lost+found。

3.16/proc目录

该目录本身是一个虚拟文件系统(virtual file system)。它只存在内存当中,而不占用外部空间。它以文件系统的方式为访问系统内核数据的操作提供接口。

3.17/sys目录

该目录与/proc类似,也是一个虚拟的文件系统,主要也是记录与核心相关的信息。包括目前已载入的核心模组与核心侦测到的硬件信息等,该目录同样不占硬盘容量。

3.18/usr目录

该目录是集成到主文件系统中的单独文件系统的挂载点,用来存放系统数据,包含大量标准子目录。/usr目的是用来存放静态数据(不随时间改变的数据),没有系统管理员的干涉不会改变的数据。

3.19/usr/bin目录

绝大部分的用户可使用指令都放在这里。

3.20/usr/include目录

c/c++等程序语言的头文件(header)与包含文件(include)放置处。

3.21/usr/lib目录

包含各应用软件的函式库、目标文件(objectfile),以及不被一般使用者惯用的执行文件或脚本(script)。

3.22/usr/local目录

统管理员在本机自行安装自己下载的软件,建议安装到此目录。

3.23/usr/sbin目录

由超级用户运行的非基本系统管理程序。

3.24/usr/share目录

放置共享文件的目录。/usr/share/doc:软件杂项的文件说明;/usr/share/zoneinfo:与时区有关的时区文件。

3.25/usr/src目录

一般原始码建议放置到这里,src有source的意思。至于核心原始码则建议放置到/usr/src/linux/目录下。

3.26/var

目录如果/usr是安装时会占用较大硬盘容量的目录,那么/var就是在系统运作后才会渐渐占用硬盘容量的目录。因为/var目录主要针对常态性变动的文件,包括缓存(cache)、登录档(logfile)以及某些软件运作所产生的文件,包括程序文件(lockfile,runfile),或者例如MySQL数据库的文件等。

3.27/var/cache目录

应用程序本身运作过程中会产生的一些缓存文件。

3.28/var/lib目录

程序本身执行的过程中,需要用到的数据文件存放目录。比如,MySQL的数据库放置到/var/lib/mysql/。

3.29/var/lock目录

某些配置或文件资源一次只能被一个应用程序所使用,如果同时有两个程序使用该装置时,就可能产生一些错误,因此就要将该资源上锁(lock),以确保该资源只会给单一程序所使用。

3.30/var/log目录

这是登录文件放置的目录。主要存放日志等信息。

3.31/var/mail目录

放置个人电子邮件信箱的目录,不过该目录也被放置到/var/spool/mail/目录中,通常这两个目录是互为链接文件。

3.32/var/run目录

某些程序或者是服务启动后,会将它们的PID放置在该目录下。

3.33/var/spool目录

该目录通常放置一些队列数据,所谓的“队列”就是排队等待其它程序使用的数据。这些数据被使用后通常都会被删除。举例来说,系统收到邮件信息会放置到/var/spool/mail/中,但使用者收下该信件后该封信原则上就会被删除。信件如果暂时寄不出去会被放到/var/spool/mqueue/中,等到被送出后就被删除。如果是工作排程数据(crontab),就会被放置到/var/spool/cron/目录中。

 个人公众号:

image.png


Guess you like

Origin blog.51cto.com/13440764/2608273