Linux file directory structure List

Learn Linux, is not limited to learning the various commands, understand the function of the directory structure of the entire Linux file system, and each directory is also essential.

 

When using Linux, a command line input  ls -l / can be seen, contains many subdirectories (referred to as a directory) in Linux root directory (/), e.g. bin, boot, dev like. Meanwhile, in each directory also contains a lot of subdirectories (called secondary directory), such as / bin / bash, / bin / ed and the like. Linux file system directory tree showing an overall structure / root directory is equivalent to the roots.

As the open source Linux system for free, so that there are a lot of Linux distributions, use Linux product development team, there are many, if everyone is allowed to follow their own ideas to configure the Linux file system directory, the latter may produce a lot of management problems. Imagine, if you enter a company file directory structure Linux systems used and learned completely different, it is a headache.

In order to avoid many users of Linux system directory structure ideas, Linux Foundation released the FHS. Most Linux distributions systems follow this standard.

FHS (Filesystem Hierarchy Standard), a hierarchical file system standard that specifies a Linux system directories and a portion of the secondary directory (/ usr and / var) use. The main purpose of publication of this standard is to allow users to clearly understand what types of files in each directory should be stored.

Linux root directory (/)

FHS believes that the root of the Linux system (/) the most important (no one), the following 2:00 reasons:

  1. All are derived from the root directory out;
  2. The root directory of the boot and system repair, restore closely related;

Therefore, the root directory must contain the boot software, the core file, start the necessary procedures, libraries, repair system program and other documents, as shown in Table 1.

Table 1 Linux a directory and its role
Level directory function)
/bin/ Storage system command, ordinary users and root can execute. Command on / under the bin may also be performed in single-user mode
/boot/ System startup directory to save the relevant files to the system start, such as the kernel files and boot loader (grub) files
/dev/ Device file save location
/etc/ Configuration file save location. All the system default installation (rpm installation) of all service profile stored in this directory, such as user information, startup scripts services, common services such as configuration files
/home/ Average user's home directory (also called the home directory). When creating users, each user must have a login and default save location of your data is the user's home directory, the home directory of all users is to create a common and user name in the same directory / home / under. The liming user's home directory is / home / liming
/lib/ Library system calls save location
/media/ Mount directory. The system proposes to mount a media device, such as floppy disks and CD-ROM
/ Mnt / Mount directory. Only this one early Linux mount directory, and no breakdown. The system proposes this directory to mount additional equipment, such as U disk, mobile hard drives and other operating system partitions
/misc/ Mount directory. The system is recommended to mount NFS shared directory services. Although the system is ready to mount the three default directory / media /, / mnt /, / misc /, but what device Where to mount a directory can be determined by the administrator himself. For example, the author at the time of contact with Linux, the default directory only mount / mnt /, so develop the habit of establishing a different directory in / mnt / under mount different devices, such as / mnt / cdrom / mount CD-ROM, / mnt / usb / mount U disk, it is possible
/opt/ Third-party software installed saved. This directory is placed in the mounting position and other software, manual installation of the software source package can be installed to this directory. But I still used the software into / usr / local / directory, that is to say, / usr / local / directory can also be used to install software
/root/ Root's home directory. Ordinary home directory in / home / under, root directly in the home directory "/" lower
/sbin/ Save command associated with the system environment settings, only root can use these commands to the system environment settings, but also some command allows ordinary users to view
/srv/ Service data directory. After some systems service is started, you can save the required data in this directory
/tmp/ Temporary directory. The system directory where temporary files in the directory, all users can access and write. This directory can not recommend storing important data, each boot is best regarded the catalog empty

FHS for a subdirectory of the root directory contains only Table 1, but other than that, the Linux system root directory usually contains several tables in the 2-level directory.

Table 2-level directory and other features
Level directory function)
/lost+found/ When an unexpected system crash or accidental shutdown, some files resulting fragments will be stored here. During system boot up, fsck tool checks here, and repair a damaged file system. This directory appears only in each partition, for example, / lost + found is the root partition backup and recovery directory, / boot / lost + found is the / boot partition backup recovery catalog
/proc/ Virtual file system. The directory data is not stored on the hard disk, but stored in memory. The main preservation system kernel, processes, external device status and network status. As / proc / cpuinfo CPU information is saved, / proc / devices List of device drivers is saved in, / proc / filesystems is to save the file system list, / proc / net is to preserve network protocol information ......
/sys/ Virtual file system. And / proc / directory is similar to that directory data are stored in memory, mainly related to the preservation of core information

Linux / usr directory

usr (note not the user), called the Unix Software Resource, this directory is used to store system software resources. FHS recommends that all developers should be reasonable to place data software products in each subdirectory of / usr directory, rather than creating a separate directory for their products.

Linux systems, all the default software are stored in the / usr directory, / usr directory is similar to Windows systems C: Windows + C: Program files complex two directories.

FHS recommendation, / usr directory should have the subdirectory shown in Table 3.

Table 3 / usr subdirectories and their function
Subdirectory function)
/usr/bin/ Storage system command, the average user and super user can execute. These commands and system start-independent, can not be performed in single-user mode
/usr/sbin/  存放根文件系统不必要的系统管理命令,如多数服务程序,只有 root 可以使用。
/usr/lib/ 应用程序调用的函数库保存位置
/usr/XllR6/ 图形界面系统保存位置
/usr/local/ 手工安装的软件保存位置。我们一般建议源码包软件安装在这个位置
/usr/share/ 应用程序的资源文件保存位置,如帮助文档、说明文档和字体目录
/usr/src/ 源码包保存位置。我们手工下载的源码包和内核源码包都可以保存到这里。不过笔者更习惯把手工下载的源码包保存到 /usr/local/src/ 目录中,把内核源码保存到 /usr/src/linux/ 目录中
/usr/include C/C++ 等编程语言头文件的放置目录

Linux /var 目录

/var 目录用于存储动态数据,例如缓存、日志文件、软件运行过程中产生的文件等。通常,此目录下建议包含如表 4 所示的这些子目录。

表 4 /var子目录及其功能
/var子目录 功能(作用)
/var/lib/ 程序运行中需要调用或改变的数据保存位置。如 MySQL 的数据库保存在 /var/lib/mysql/ 目录中
/var/log/ 登陆文件放置的目录,其中所包含比较重要的文件如 /var/log/messages, /var/log/wtmp 等。
/var/run/ 一些服务和程序运行后,它们的 PID(进程 ID)保存位置
/var/spool/ 里面主要都是一些临时存放,随时会被用户所调用的数据,例如 /var/spool/mail/ 存放新收到的邮件,/var/spool/cron/ 存放系统定时任务。
/var/www/ RPM 包安装的 Apache 的网页主目录
/var/nis和/var/yp NIS 服务机制所使用的目录,nis 主要记录所有网络中每一个 client 的连接信息;yp 是 linux 的 nis 服务的日志文件存放的目录
/var/tmp 一些应用程序在安装或执行时,需要在重启后使用的某些文件,此目录能将该类文件暂时存放起来,完成后再行删除

根据以上各表列举的各目录及作用,如果我们要做一些实验和练习,需要创建一些临时文件,应该保存在哪里呢?

答案是用户的主目录或 /tmp/ 临时目录。但是要小心有些目录中不能直接修改和保存数据,比如 /proc/fn/sys/ 目录,因为它们是保存在内存中的,如果在这里写入数据,那么你的内存会越来越小,直至死机;/boot/ 目录也不能保存额外数据,因为 /boot/ 目录会单独分区作为启动分区,如果没有空闲空间,则会导致系统不能正常启动。

总之,Linux 要在合理的目录下进行操作和修改。

发布了33 篇原创文章 · 获赞 0 · 访问量 414

Guess you like

Origin blog.csdn.net/linuxanz/article/details/103460893