One Linux command per day (--linux) directory structure (i)

Source: Internet
Author: User

For every Linux learner, understanding the directory structure of a Linux file system is a crucial step in learning Linux, and getting to know the standard of the Linux file directory structure and the detailed functionality of each directory is critical to our use of a good Linux system. Knowledge about the Linux directory structure.

When using Linux, if you go through ls-l/you will find that there are a lot of directories, such as etc usr Var bin and other directories, and in these directories, we go to see, found there are many directories or files. The file system looks like a tree structure under Linux, so we can refer to the structure of the file system as a tree-shaped structure.

File system is used to organize and arrange file access, so it is visible, in Linux, we can use LS and other tools to view its structure, in the Linux system, we see the tree structure, such as the operating system installed in a file system, it is represented by/starting tree structure. At the top of the Linux filesystem is/, we call the Linux root, which is the filesystem of the Linux operating system. The Linux file System entry is/, all directories, files, devices are in/below,/is the Linux file system Organizer, is also the most superior leader.

Since Linux is developing source code, major companies and organizations do their own programming according to the core code of Linux. This causes the directory under the root to be different. This creates a PC where individuals cannot use other people's Linux systems. Because you don't even know the basic configuration, where the files are. This creates confusion. This is why the FHS (Filesystem Hierarchy Standard) Institution was born. The organization is a voluntary group of Linux enthusiasts, mainly to make some basic requirements for Linux, not the operator to change a host to become the Linux illiteracy

According to FHS's official paper, the main purpose of the http://www.pathname.com/fhs/is to let users know where the installed software is usually located, so they want independent software developers, OS makers, and users who want to maintain the system, are able to follow the FHS standard. In other words, the focus of FHS is to standardize what data should be placed in each particular directory. This is a lot of benefit because the Linux operating system is able to develop the unique style that developers want under the existing landscape (directory architecture unchanged).

In fact, FHS is based on the past of the stunning has been continuously revised, FHS based on the use of the file system and whether or not to allow users to change randomly, and the directory is defined as four interactive forms, in the form of a bit like the bottom:

Shareable (shareable) Non-shareable (unshareable)
Constant (Static)

/usr (software placement)

/OPT (third party collaboration software)

/etc (config file)

/boot (boot and core documentation)

Variable (variable)

/var/mail (user email)

/var/spool/news (News Group)

/var/run (program-related)

/var/lock (program-related)

Four types of:

1. Shareable: can be shared to other systems hanging in the use of the directory, so contains the execution of files and users of the message, is able to share to other hosts on the network mounted directory;

2. Non-shareable: The device file or the socket file related to the program is not suitable for sharing with other hosts because it is only related to its own machine.

3. Constant: Some data will not change frequently, follow the distribution without change. For example, the function library, file description file, the system administrator manages the host service configuration file and so on;

4. Volatile: frequently changing data, such as log-in files, newsgroups that are generally accepted by users, etc.

In fact, FHS only defines what data should be placed under the three-level directory for the directory tree schema, which is the definition of the three directories below:

/(Root, root directory) related to boot system;

/usr (Unix software Resource) related to software Installation/execution

/var (variable) related to system operation process

First, the meaning and content of the root directory.

The root directory is the most important directory for the entire system, because not only are all directories derived from the root directory, but the root directory is related to actions such as boot/restore/system repair. As the system starts with the need for specific power-on software, core files, boot required programs, function libraries and other file data, if the system error occurs, the root directory must also include the ability to repair the file system process. Because with the directory is so important, so in terms of FHS requirements, he wants the root directory is not placed in a very large partition, because the larger the partition you will put more data, so that the root directory of the partition there may be more error opportunities.

Therefore, the FHS standard recommendation: The root directory/partition should be smaller the better, and the application installed software should not be placed in the same partition with the root directory, keep the root directory smaller the better. This is not only good performance, the root directory is located in the file system is less prone to problems. To be blunt, the root directory is the same as the C disk of Windows.

For these reasons, FHS that the following directories should be included in the root directory:

Directory File contents should be placed
/bin

The system has many directories to place the execution files, but/bin is more special. Thought that/bin placed in the single-person maintenance mode can also

Instructions that are sufficient to be manipulated. The instructions under/bin can be used by root and general account,

Mainly include: Cat.chmod,chown,date,mv,mkdir,cp,bash and other commonly used directives.

/boot

The main place of the boot will use the file, including the Linux core files and boot options and boot required profiles and so on.

Linux kernel commonly used files are: Vmlinuz, if you are using GRUB this boot management program,

There will also be/boot/grub this directory

/dev

On Linux systems, any device and peripherals are in the form of a file with this directory.

Simply by accessing a file in this directory, you are accessing a device. The more important files are:

/dev/null,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*, etc.

/etc

Most of the system configuration files are placed in this directory, such as the person's account password, the starting document of various services.

In general, the various file attributes in this directory can be queried by general users, but only Root has the right to modify.

FHS does not recommend placing executable files (binary) in this directory.

The more important files are:/etc/inittab,/etc/init.d/,/etc/modprobe.conf/etc/x11/etc/fatab

/etc/sysconfig and so on.

In addition, the following important directory is:/ETC/INIT.D all services of the preset start script is placed here.

For example, to start or close iptables:/etc/init.d/iptables strat

/etc/xinetd.d This is the so-called Super Daemon Management of the various service profiles directory

/etc/x11 the various profiles associated with the X Window are here,

In particular, xorg.conf or xf86config these two X server profiles.

/home

This is the user home directory of the system presets. When you add a general user account,

The pre-set user home directory will be standardized here. More importantly, the home directory has two types of code:

~: Represents the current user's home directory,

~guest: Represents the home directory where the user name is guest

/lib

The system has a much more functional library, and/lib places the function libraries that will be used at boot time, as well as in/bin or/sbin

The bottom of the instruction will call the function library. What's the function library? You can think of it as a plug-in, and some commands must be

It is necessary to have these plug-ins to successfully complete the program implementation of meaning. It is especially important to/lib/modules this directory,

Because the directory will place core-related modules (drivers)

/media

Media is the medium of the English language, the/media is placed under the device can be removed. Including

Soft disc, CD, DVD and so on device, common file name:/media/floppy,/media/cdrom

/mnt

If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory.

In the early days, this directory was used in the same way as/media. Just after the/media, this

The catalog is used for temporary use.

/opt

This is the directory to which the third-party protocol software is placed. What is third party software? For example:

The KDE desktop management system is a standalone program, but it can be installed on a Linux system,

Once, KDE software is recommended to be placed in this directory. Also, if you want to install additional software on your own,

Then you can also install your software into the/OPT directory. Or someone else is accustomed to placing it under the/usr/local directory.

/root

The home directory of the system administrator (root). The reason for this is that if you enter the single-player maintenance mode and only

When the root directory is mounted, the directory can have the root home directory, and all we would like Root's home directory to be

The directory is placed in the same partition.

/sbin

Linux has a lot of instructions to set the system environment, these instructions only root can be used to set up the system,

Other users can only use queries. Placed under the/sbin, is required during the boot process,

It includes the instructions needed to boot, repair, and restore the system. As for some server software programs, general

is placed in the/usr/sbin. As for the system execution documentation generated by the natively installed software,

is placed in the/usr/local/sbin,

Common directives include the following: Fdisk fsck ifconfig init mkfs

/srv

SRV can be regarded as the abbreviation of service, which is the data directory that is needed after some network services are started.

Common services such as: www ftp, for example, the WWW server needs to be placed on the Web page information

/srv/www inside

/tmp

This is where the general user or an executing program temporarily places the file. This directory is accessible to anyone.

So we need to clean it up regularly. Of course, important information cannot be placed in this directory. Prevented from being mistakenly deleted.

In fact, the criteria defined by FHS for the catalogue are limited to the table above, but there are still some catalogs that need me to know.

Directory

File contents should be placed

/lost+found

This directory is a directory created using the standard EXT2/EXT3 file format, which is intended to be used when an error occurs in the file system.

Place some missing fragments in this directory. This directory is usually partitioned to the top-level,

For example, if you add a hard drive to/disk, it will automatically generate a directory under this system/disk/lost+found

/proc

The directory itself is a virtual file system (Vsan filesystem). The information it places is in memory,

such as system core, process information, peripheral status and network status. Because the information in this directory is in memory,

So itself does not occupy any hard disk space.

The more important files are:/proc/cpuinfo,/PROC/DMA,/proc/interrupts,/proc/ioports,/proc/net/*

/sys

This directory is in fact very similar to/proc, is also a virtual file system, mainly records and core-related content.

This includes the core modules currently loaded and the core detected hardware. This directory also does not account for hard disk capacity.

In addition to the contents of these directories, it is also important to note that because the root directory and boot-related, the boot process only the root directory will be mounted, the other partition is the boot after the completion of the continuous mount behavior.

Because of this, the directory associated with the boot process in the root directory cannot be placed in a different partition than the root directory. Which directories cannot be separated from the root directory?

/etc configuration file

/bin Important Execution files

The device files required by/dev

/lib function Libraries required for executing files and core required modules

/sbin Important System Execution files

Today this article is slightly longer, all in two. Otherwise, it's too much to remember.

One Linux command per day (--linux) directory structure (i)

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.