Linux operating system

Source: Internet
Author: User

After a long period of development, many users are familiar with Linux. I like the Linux operating system very much. Let's talk about this in detail. I have been in touch with the Linux operating system for some time. However, when I compile open-source programs these days, I found that I did not have a thorough understanding of the directory structure of the Linux operating system, many important directories are not clear about what they are for. Therefore, Baidu gave an introduction to this topic on the Internet. According to their usage habits, I have compiled an article about the directory structure of the Linux File System and shared it with you. This article describes all directories in the Linux operating system and focuses on important directories to help beginners master the directory structure of the Linux operating system. At the same time, the last appendix of the article contains a concise manual on the Linux directory structure for your reference.

What is a file system?

When you use the Linux operating system, if you use ls-l/, 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. At the top of the Linux operating system is/, which is called/as the root of Linux, that is, the file system of the Linux operating system. The entry to the Linux operating system is/. All directories, files, and devices are under/./is the organizer of the Linux File System and the highest-level leader.

File System Type

Linux has four types of basic file systems: common files, directory files, connection files, and special files, which can be identified by the file command.
Common files: such as text files, C language Meta-code, SHELL scripts, binary executable files, etc. You can use cat, less, more, vi, and emacs to view the content and change the name using mv.
Directory file: including the file name, subdirectory name, and pointer. It is the only place for storing file names in LINUX. You can use ls to List Directory files.
Connection file: Directory Entries pointing to the same index node. Use ls to check whether the mark of the connection file starts with l, and "->" points to the connected file at the end of the file.
Special files: Some LINUX devices, such as disks, terminals, and printers, are displayed in the file system. A type of files are special files, which are usually stored in the/dev directory. For example, soft drive A is called/dev/fd0. LINUX does not have the concept of C:, but uses/dev/had from the first hard disk.

Detailed explanation of the directory structure

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 operating 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 almost the same.
Let's get down to the point. Here we will talk about the core part of this article: the directory structure of the Linux operating system.

/The entry to the Linux operating system is also the directory at the highest level;
The commands required by the/bin system are located in this directory, such as ls, cp, and mkdir. The functions are similar to those of/usr/bin, all files in this directory are executable and can be used by common users. The most basic command required by the basic system is put here.
/Boot the Linux operating system kernel and the file directory required by the boot system program. For example, the vmlinuz initrd. img file is located 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 here 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/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.
/When the proc operating system is running, the process information 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 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;

Explanation of important subdirectories

The following is a few more common and important directories.
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.

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/share system stores shared items. For example,/usr/share/fonts is a font directory,/usr/share/doc, and/usr/share/man help file.
/Usr/src is the directory of the kernel source code storage, such as the following kernel source code directory, such as Linux operating system, 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.
/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;

Appendix: concise reference manual for the directory structure

(1) the "/" root directory contains the following sub-directories:
The/usr directory contains all commands, libraries, documents, and other files. These files will not be changed during normal operations. This directory also contains the main applications of your Linux release version, such as Netscape.
The/var directory contains files changed during normal operations: offline files, record files, lock files, temporary files, and page formatting files.
The/home directory contains User Files: parameter setting files, personalized files, documents, data, emails, and cached data. This directory should be retained at the provincial level.
The/proc directory contains the entire illusory file. They do not actually exist on the disk or occupy any space. Ls-l can be used to display the size of these files.) When you view these files, it is actually accessing information in the memory, which is used to access the system.
The binary execution files required when the/bin system is started. These files can be used by common users.
/Sbin system execution file binary), these files are not intended to be used by common users. Normal users can still use them, but they must specify directories .)

/Etc operating system configuration file directory.

/Root system administrator is also called a Super User or root user) Home directory.
/Dev device file directory. In Linux, devices are treated as files, so that the hardware is abstracted to facilitate read/write, network sharing, and temporary loading to the file system. Normally, the device has an independent sub-directory. The contents of these devices appear in separate subdirectories. The Linux operating system does not have any driver.
/Lib shared libraries of programs and core modules in the root file system directory.
/Boot is used to upload LILO or GRUB files. When a computer is started with multiple operating systems, you may be allowed to select which operating system to start.) These files are first loaded. This directory also contains the Linux kernel compressed file vmlinuz), but the LINUX kernel can also exist elsewhere, as long as LILO is configured and LILO knows where the LINUX kernel is.
Optional/opt applications, such as kde redhat 5.2 in REDHAT 6.0, KDE is placed in other XWINDOWS applications, and the main execution program is in the/usr/bin directory)
/Tmp temporary file. The directory is automatically cleaned up.
/Lost + found files recovered during File System Repair

(2) important parts in the "/usr" directory are:
/Usr/X11R6 X-WINDOWS System version 11, release 6)
/Usr/X11 is connected with/usr/X11R6/usr/X11R6)
/Usr/X11R6/bin a large number of small X-WINDOWS applications may also be a symbolic connection to large execution files in other subdirectories ).
/Usr/doc documentation for Linux operating systems in the updated system, this directory is moved to/usr/share/doc ).
/Usr/share data that is independent of your computer structure, such as words in the dictionary.
/Usr/bin and/usr/sbin are similar to/bin and/sbin under the "/" root directory, in emergency maintenance ). Most commands are in this directory.
/Usr/local applications installed by the local administrator may also have separate subdirectories for each application ). After "main" is installed, this directory may be empty. Contents in this directory should exist after the operating system is re-installed or upgraded.
/Usr/local/bin may be a small application installed by the user, which is connected with symbols of some large applications in the/usr/local directory.

(3) Contents of the "/proc" directory:
/Proc/cpuinfo information about the processor, such as the type, manufacturer, model, and performance.
The list of all devices configured for/proc/devices to run the kernel.
/Proc/dma the DMA channel currently in use. /Proc/filesystems: The file system configured for running the kernel.
/Proc/interrupts is in use, and how many interruptions have occurred.
/Proc/ioports is currently using the I/O port.

This article is an integral part of the Linux File System. It is essential for a series of documents. The purpose of writing this article is to provide a reference manual for Linux operating system learners about the directory structure of Linux operating system file systems. If you do not know, please contact the flying, you can go to my message book http://www.piaoyang.org/guestbook to leave a message for me, I will try my best to answer your questions. In this example, I hope to provide you with some help.

  1. Advantages of the Linux operating system that attracts us
  2. Linux operating system history
  3. Easily retrieve the lost root password in the Linux operating system
  4. Analyze the Linux and Windows operating systems for you
  5. Introduction to Fedora 7 linux operating system DVD

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.