I like Linux File System very much. I also like to sum up the experience and lessons of Linux File System in my work. Let's talk about this in detail. The Linux File System is in a tree structure. To understand the directory structure of the Linux file system, it is necessary for us to control Linux. This document describes important directories in Linux.
The structure of the Linux File System is a tree structure. The entry begins with/to understand the structure of the Linux File System. It is one of the basic knowledge points that we need to master.
1. What is a file system;
See: Linux File System Overview
2. Brief description of the organizational structure of the file system;
When you use a Linux file system, if you use ls-la/, you will find that there are many directories under, for example, etc, usr, var, bin ...... and in these directories, we went in and saw that there are also many directories or files. The file system looks like a tree structure in Linux, so we can call the structure image of the file system a tree structure.
You can use the tree Command to view the structure of the file system;
[Root @ localhost ~] # Tree
However, the tree Command has disappeared in Fedora Core 5.0 and is retained in Slackware 10.2. However, in other versions of Linux, the output result of the tree Command shows that the top part should be "/", which we call "/" as the Linux root, that is, the Linux operating system. The entry to the Linux File System is/. All directories, files, and devices are under/./is the organizer of the Linux File System and the highest-level leader.
Next we will list the main directories in the tree structure of the Linux File System.
3. Analysis of the organizational structure of the file system;
What can we analyze the organizational structure of a file system? That is, when we see the/usr,/etc ...... /var and other directories are used for specific purposes. No matter which version of the Linux File System has these directories, these directories should be standard. Of course, there will also be some minor differences in each Linux release version, but in general, it is still roughly the same.
In fact, there are few differences between Linux releases. The differences are mainly manifested in the differences between system management Special se tools and software package management methods. In addition, there is no big difference; for example, the rpm ora software package management tool is rpm, And the Slackware is pkgtool or installpkg;
Let's get down to the point. Next we will talk about the organizational structure of the file system.
/Linux File System entry, which is also at the highest level of directory;
The commands required by the/bin basic system are located in this directory, which is also required by the minimum system. commands such as ls, cp, and mkdir are similar to/usr/bin, all files in this directory are executable and can be used by common users. The most basic command required for the basic system is put here.
/Boot Linux kernel and the files required by the boot system program, such as vmlinuz initrd. img files, are all in this directory. In general, GRUB or LILO System Boot manager is also located in this directory;
/Dev device file storage directory, such as sound card, disk ......
The location of the/etc system configuration file, where some server configuration files are also located, such as the user account and password configuration files;
/Home: the default home directory for normal users;
/Lib library file storage directory
/Lost found in the ext2 or ext3 file system, some file fragments are generated when the system crashes or the machine shuts down unexpectedly. When the system is started, the fsck tool checks this and fixes corrupted file systems. Sometimes a system problem occurs. Many files are moved to this directory and may be repaired manually or moved to the original location.
/The mount point of the media plug-and-play storage device is automatically created under this directory. For example, after the USB disk system is automatically mounted, a directory is generated under this directory; after CDROM/DVD is automatically mounted, a directory will also be created in this directory, similar to the cdrom directory. This is available only on the latest release kit, such as Fedora Core 4.0 5.0. See the definition of/etc/fstab;
/Misc
The/mnt directory is generally used to store the mounted directory of the mounted storage device, such as the cdrom directory. See the definition of/etc/fstab. Sometimes we can enable the system to automatically mount the file system at startup and put the mount point here. It mainly depends on the definition in/etc/fstab. For example, the optical drive can be mounted to/mnt/cdrom.
/Opt indicates the optional meaning. Some software packages will also be installed here, that is, custom software packages. For example, in Fedora Core 5.0, OpenOffice is installed here. Some software packages compiled by ourselves can be installed in this directory. The software installed through the source package can be installed through the./configure -- prefix =/opt/directory.
/Program running in the proc operating system) and kernel information such as cpu, hard disk partition, and memory information) are stored here. The/proc directory is the mounted directory of the file system proc disguised. proc is not a real file system. For its definition, see/etc/fstab.
/Root Linux super privilege user root's home directory;
/Sbin stores mostly commands related to system management. It is the place where super-privileged root users can execute executable commands. ordinary users do not have the permission to execute commands in this directory, this directory is similar to/usr/sbin;/usr/X11R6/sbin or/usr/local/sbin. Just remember it, all contents contained in sbin can be executed only with the root permission.
/Tmp temporary file directory. Sometimes, when you run a program, a temporary file is generated. /Tmp is used to store temporary files. The/var/tmp directory is similar to this directory.
/Usr is the directory where the system stores programs, such as commands and help files. This directory contains many files and directories. Most of the software packages officially provided by the Linux release are installed here. If a server configuration file is involved, the configuration file will be installed in the/etc directory. The/usr directory contains the/usr/share/fonts directory, the help directory/usr/share/man or/usr/share/doc, common users can execute the file directory/usr/bin or/usr/local/bin or/usr/X11R6/bin. The root executable command can be stored in the directory, for example,/usr/sbin or/usr/X11R6/sbin or/usr/local/sbin, And the header file directory of the Program/usr/include.
The content of the/var directory is changed frequently. You can see the name of the Directory, which is abbreviated as vary./var contains/var/log, which is the directory used to store system logs. The/var/www directory defines the directory where the Apache server site is stored;/var/lib is used to store some library files, such as MySQL and the location where the MySQL database is stored;
Let's add some important contents;
The/etc/init. d directory is used to store scripts started by the System or server in System V mode, which is common in Systems started or initialized in System V mode. For example, Fedora/RedHat;
/Etc/xinit. d if the server runs in xinetd mode, put its script in this directory. Some systems do not have this directory, such as Slackware, and some old versions do not. In Rehat/Fedora, a new version is compared.
/Etc/rc. d is a directory of the Slackware release, where the bsd startup script is stored, such as defining the NIC and enabling the script on the server.
/Etc/X11 is the location for storing configuration files related to X-Windows;
For example:
[Root @ localhost ~] #/Etc/init. d/sshd start Note: start the sshd server
[Root @ localhost ~] #/Etc/init. d/sshd stop Note: stop the sshd server
Start sshd: [OK]
This is a typical sshd server startup script in System V mode. You can run this script to start the sshd server.
The/usr/bin directory is the directory of executable programs, and normal users have the permission to execute them. When we install a program from the software package that comes with the system, most of his executable files are stored in this directory. For example, when installing the gaim software package. A similar directory is/usr/local/bin. Sometimes the file in/usr/bin is a link file of/usr/local/bin;
The/usr/sbin directory is also the directory of executable programs, but most of them store commands related to system management. Only the root permission can be executed. Similar directories include/sbin or/usr/local/sbin or/usr/X11R6/sbin;
The/usr/local directory is generally used to store the user's self-compiled and installed software. It is generally installed through the source code package. If the installation directory is not specified, it is usually installed in this directory. This directory contains subdirectories. Let's take a look.
The/usr/lib directory is similar to the/lib directory, which is the storage directory of the library files;
The/usr/share system stores shared items. For example,/usr/share/fonts is a font Directory, which is shared by users.
/Usr/share/doc and/usr/share/man help files are also shared;
/Usr/src is the directory of the kernel source code storage, such as the following kernel source code directory, such as linux, linux-2.xxx.xx directory. Some systems also install the source code package here. For example, Fedora/Redhat. When we install file. src. rpm, these packages will be installed in the corresponding directory of/usr/src/redhat. See file. src. rpm for a brief introduction. In addition, for Fedhat 4.0 5.0, the Directory of his kernel source code package is located in a directory under the/usr/src/kernels directory and the corresponding directory is generated only after installation );
/Var/adm, such as the installation information, logs, and management information of the software package, has this directory in the Slackware operating system. It does not seem to exist in Fedora; check it yourself.
/Var/log system log storage. The log analysis depends on the contents in this directory;
/Var/spool printer, email, proxy server, and other offline directories;
4. Matters not covered in this article;
Because there are many Linux releases, there is always a difference, but it is still similar in general. Take a look at the multi-column directory and you will understand it. There are many Windows directories, and we don't know what it is used for, but we also use Windows. Now, in Linux, you can click the mouse to view these directories. If you don't use the command, you will always see it when you click it, right?
5. About this article;
This article is an integral part of the Linux File System. It is essential for a series of documents and is also one of the basic documents. This is because I have thought about how to use Linux Files. New handwritten .......
6. postscript;
Writing a document is a persistent process. Writing a document still gives me a lot of fun. I don't feel much pain when I write a document at leisure. If one thing is regarded as a stress, there is no fun. If so, it is better not to do it. Later, I may write content related to the Linux File System, such as creating, deleting, moving, attributes, and permissions;
7. References
Man fstab
8. Related Documents
Linux File System Overview
- Introduction to Linux File System partitions
- Learning diary: Linux File System Restrictions and features
- Ext3 and Reiserfs are bad Linux file systems.
- Describe Linux File System BTRFS
- Modularization of Linux File System Installation