The Directory Structure of The Linux File System

Source: Internet
Author: User
Keywords linux linux file system linux file system structure
The structure of the Linux file system is a tree structure. The entry starts from /. Understanding the structure of the Linux file system is one of the basic knowledge points that we need to control.



1. Brief description of the organization structure of the file system;
When you use Linux, if you pass ls -la / you will find that there are many directories under /, such as etc, usr, var, bin...
Waiting for directories, and in these directories, we went in and found that there are also many directories or files. The file system looks like a tree structure under Linux, so we can call the structure of the file system visually
Tree structure.
View the structure of the file system, we can achieve it through the tree command;
[root@localhost ~]# tree
However, the tree command has now disappeared in Fedora Core 5.0, and in Slackware
There are still reservations in the 10.2 version. But other versions of Linux should have; judging from the output of the tree command, the top should be /, we call / the root of Linux, which is
The file system of the Linux operating system. The entrance of the Linux file system is /, and all directories, files, and devices are under /. / is the organizer of the Linux file system and the top level
leader.


2. Analysis of the organization structure of the file system;
Analysis of the organization structure of the file system, what can we analyze? That is, when we list / directories, we see /usr, /etc... /var
What is the purpose of waiting for the catalog? Are these catalogs for specific purposes? No matter which version of the Linux system, there are these directories, and these directories should be standard. Of course each Linux distribution
There will be some small differences in the book, but overall, it is still roughly the same.
The differences between Linux distributions are actually very few. The differences are mainly the differences in the current system management tools and package management methods. Other than that, there is no big difference; for example, the Fedora package management tool is rpm, while Slackware Is pkgtool or installpkg, etc.;
Closer to home, let's talk about the file system organization structure.
/ The entry of the Linux file system is also the highest level directory;
The commands required by the /bin basic system are located in this directory, which are also commands required by the minimal system; such as ls, cp, mkdir and other commands; the function is similar to /usr/bin, the files in this directory are all executable, ordinary Commands that users can use. The most basic commands needed as a basic system are placed here.
/boot Linux kernel and files needed for booting system programs, such as vmlinuz initrd.img file are located in this directory. In general, the 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 setting file, and some server setting files are also here; such as user account and password setting files;
/home The home directory of ordinary users is the default storage directory;
/lib library file storage directory
/lost+found
In the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are generated here. When the system starts, the fsck tool will check this and repair the damaged
Bad file system. Sometimes a problem occurs in the system and a lot of files are moved to this directory, which may be repaired manually or moved to the original location.
/media The mount point of the plug-and-play storage device is automatically created in this directory, for example, after the USB disk system is automatically mounted, a directory will be created in this directory
; After the CDROM/DVD is automatically mounted, a directory will be created in this directory, similar to the cdrom directory. This is only available in the latest distribution, such as Fedora
Core 4.0 5.0 etc. Can refer to the definition of /etc/fstab;
/misc
/mnt This directory is generally used to store the mount directory of the mounted storage device, such as cdrom
And other directories. See the definition of /etc/fstab. Sometimes we can let the system boot to automatically mount the file system, and it is also possible to put the mount point here. Mainly depends on what is in /etc/fstab
What is defined; for example, CD-ROM drives can be mounted to /mnt/cdrom.
/opt means optional, some software packages will also be installed here, that is, custom software packages, such as Fedora Core
In 5.0, OpenOffice is installed here. Some software packages compiled by ourselves can be installed in this directory; software installed through source packages can be installed through
./configure --prefix=/opt/ directory.
/proc When the operating system is running, process (running program) information and kernel information (such as cpu, hard disk partition, memory information, etc.) are stored here. The /proc directory pretends to be the mount directory of the file system proc. proc is not a real file system, and its definition can be found in /etc/fstab.
/root Home directory of the ultimate Linux user root;
/sbin
Most of the commands related to system management are stored, which is the storage location of the executable commands of the ultimate user root. Ordinary users have no permission to execute the commands in this directory, this directory and /usr/sbin;
The /usr/X11R6/sbin or /usr/local/sbin directory is similar;
Just remember, all the directories contained in the sbin directory can only be executed with root privileges.
/tmp Temporary file directory, sometimes when the user runs the program, temporary files will be generated. /tmp is used to store temporary files. The /var/tmp directory is similar to this directory.
/usr
This is the directory where the system stores programs, such as commands, help files, etc. There are many files and directories in this directory. When we install a package officially provided by a Linux distribution, most of them are installed here.
If there is a server setting file, the setting file will be installed in the /etc directory. The /usr directory includes the font directory /usr/share/fonts and the help directory
/usr/share/man or /usr/share/doc, ordinary user executable file directory /usr/bin or /usr/local/bin
Or /usr/X11R6/bin, the directory where the executable commands of the ultimate user root are stored, such as /usr/sbin or /usr/X11R6/sbin
Or /usr/local/sbin, etc.; more program header files are stored in the directory /usr/include.
The content of the /var directory changes frequently. You can see by the name. We can understand it as the abbreviation of vary. There is /var/log under /var
This is the directory used to store system logs. The /var/www directory defines the directory where the Apache server site is stored; /var/lib
Used to store some library files, such as MySQL, and the storage location of MySQL database;
Let's add some more important catalogues;
/etc/init.d This directory is used to store scripts for the system or server to start in System V mode, which is common in systems that are started or initialized in System V mode. Such as Fedora/RedHat;
/etc/xinit.d If the server is running in xinetd mode, its script should be placed in this directory. Some systems do not have this directory, such as Slackware, and some older versions do not. It exists in a relatively new version in Rehat/Fedora.
/etc/rc.d This is a directory of the Slackware distribution. It is the storage location of BSD startup scripts; such as defining network cards and server startup scripts.
/etc/X11 is the storage location of X-window system related setting files;
For example, the following 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 System V mode startup script. Run this script here to start the sshd server.
The directory /usr/bin is the directory of executable programs, and ordinary users have the authority to execute them;
When we install a program from the software package that comes with the system, most of its executable files will be placed in this directory. For example, when installing the gaim package. A similar directory is /usr/local/bin;
Sometimes the file in /usr/bin is the link file of /usr/local/bin;
The /usr/sbin directory is also a directory for executable programs, but most of them store commands related to system management. Only root privileges can be executed; similar directories are /sbin or /usr/local/sbin or /usr/X11R6/sbin, etc.;
/usr/local This directory is generally used to store the storage directory of user self-compiled and installed software; it is generally the software installed through the source code package. If the installation directory is not specified, it is generally installed in this directory. There are subdirectories under this directory. See it for yourself.
/usr/lib is similar to the /lib directory, which is the storage directory of library files;
/usr/share The storage location of things shared by the system, for example, /usr/share/fonts is the font directory, which is shared by all users.
The /usr/share/doc and /usr/share/man help files are also shared;
/usr/src is the directory where the kernel source code is stored. For example, there is a kernel source code directory below, such as linux, linux-2.xxx.xx
Catalog etc. Some systems also install source code packages here. For example, Fedora/Redhat, when we install file.src.rpm, these packages will be installed in
/usr/src/redhat in the corresponding directory. Please refer to:
"A brief introduction to the use of file.src.rpm"
. In addition to Fedhat 4.0 5.0, the directory of his kernel source package is located in a directory under the /usr/src/kernels directory (the corresponding directory will only be generated after installation);
/var/adm Such as software package installation information, logs, management information, etc., there is this directory in the Slackware operating system. It seems not in Fedora; see for yourself.
/var/log System log storage, analysis of the log depends on the contents of this directory;
/var/spool Spool directories for printers, mail, proxy servers, etc.;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.