Linux Directory Configuration

Source: Internet
Author: User
Tags time zones

One, Linux directory configuration standard: FHS

The focus of FHS (Filessystem Hierarchy Standard) is to standardize what data should be placed in each particular directory.

FHS whether or not the file system is used frequently or not allows the user to arbitrarily change, and the directory is defined as four kinds of interactive form.

Shareable (shareable) Non-shareable (unshareable)
Constant (Static) /usr (software placement) /etc (config file)
/OPT (third-party software) /boot (boot with kernel file)
Variable (variable) /var/mail (User mail box) /var/run (program-related)
/var/spool/news (News Group) /var/lock (program-related)

A. Shareable: can be shared with other systems to mount the use of the directory, so including the execution of files and users of the mail and other data, is able to share to other hosts on the network mounted directory.

B. Non-shareable: device files running on their own machine or socket files related to the program, etc., because they are only related to their own machines, so of course it is not appropriate to share to other hosts
C. Constant: Some data will not change constantly, with the distribution without change. Examples include function libraries, file description files, host service profiles managed by system administrators, and so on.

d. Variable: frequently changing data such as login files, newsgroups, etc.

FHS defines what data should be placed on a three-tier directory for a directory tree schema:

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

/usr (UNIX software Resource): Related to Software Installation/execution

/var (variable): Related to System operation process

 1. The meaning and content of the root directory (/)

    The root directory is related to operations such as power-on, restore, and system repair.

    FHS Standard Recommendation: The root directory (/) should be the smaller the partition should be the better, and the software installed by the application should not be placed in the same partition as the root directory, keep the root directory as small as possible, so not only good performance, the root directory of the file system is less prone to problems.

  

FHS define the root directory (/) below should be the existence of these subdirectories:

  

Directory File contents should be placed
/bin The system has a lot of directories for executing files, but/bin is more special. because/bin places commands that can be manipulated in single-user maintenance mode . In/bin the following commands can be used by root and general account, mainly with Cat,chmod,chown,date,mv,mkdir, Cp,bash and other commonly used commands.
/boot

This directory mainly places the files that will be used to boot, including the Linux kernel files and the boot menu and the required configuration files . LINUX kernel commonly used file name is Vmlinuz, if you use grub this boot loader, there will also be/boot/grub/this directory

/dev On Linux systems, any device and interface device exists in this directory in the form of files . You simply access a device by accessing one of the files under this directory. More important documents are/dev/null,/dev/zero,/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 file, the various service start files, etc. In general, the file attributes in this directory are accessible to the general user, but only root has the right to modify. FHS does not recommend placing executable files (binary) in this directory . The more important documents are Etc/inittab,/ETC/INIT.D,/etc/modprobe.conf,/etc/x11,/etc/fstab,/etc/sysconfig, etc., in addition, the following important directories are:

A./etc/init.d/: The default startup scripts for all services are placed here, for example to start or close iptables: "/etc/init.d/iptables start", "/etc/init.d/iptables Stop"

B./etc/xinetd.d/: This is the configuration file directory of the various services called Super Daemon Management

C./etc/x11/: Various configuration files related to X window are here, especially xorg.conf this xserver configuration file

/home

This is the default user home folder (home directory). When you create a general user account, the default User home folder is regulated here . More importantly, the home folder has two types of code:

~: Represents the current user's home folder

~dmtsai: Represents Dmtsai's home folder

/lib The system has a lot of libraries, and the/L IB places the library offunctions that will be used at boot time, and the function libraries that are called by the commands below/bin or/sbin . What is a function library? You can think of it as a "plug-in", some commands must have these "plug-in" to be able to successfully complete the implementation of the program meaning. It is particularly important to/lib/modules/this directory because it will place kernel-related modules (drivers)
/media The/media place is a removable device. devices, including floppy disks, CDs, DVDs , and so on, are temporarily mounted here. Common filenames are/media/floppy,/media/cdrom, etc.
/mnt If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In earlier times, this directory was used in the same way as/media. Only after having/media, this directory is used to temporarily hang up the
/opt /OPT, a directory where third-party software is placed.
/root the home folder of the system administrator (root) . The reason for this is that if you go into single-user maintenance mode and only mount the root directory, that directory will be able to have the root home folder, so we would like Root's home folder and root directory to be placed in the same partition
/sbin Linux has a lot of commands to set up the system environment, these commands only root can use to "set up" the system, other users can only be used to "query" only. placed under the/sbin for the boot process required, which includes the boot, repair, restore the system required commands . As for some server software programs, it is generally placed in the/usr/sbin/. The system execution file (Systen binary) generated by the natively installed software is placed in the/usr/local/sbin/. Common commands include Fdisk, fsck, ifconfig, INIT,MKFS, etc.
/srv SRV can be considered an abbreviation for "service", which is the data directory to be used by some network services after they are started. Common services such as www,ftp, for example, the Web page data required by the WWW service can be placed in/srv/www/
/tmp This is where the general user or the executing program temporarily places the file. This directory is accessible to anyone, so you need to clean it up regularly. Of course, important data cannot be placed in this directory. Because FHS even recommends that you remove the data from/TMP when booting

    

In fact FHS the criteria defined for the root directory are only the data listed above. Here are a few of the most important directories in Linux:

Directory File contents should be placed
/lost+found This directory uses the standard EXT2/EXT3 file system format to produce a directory that is intended to place some of the missing fragments into this directory when a file system error occurs . This directory usually exists at the top level of the partition, for example, if you add a hard disk and/disk, it will automatically generate a directory "/disk/lost+found" in this system.
/proc The directory itself is a virtual file system (Vsan filesystem). it places the data in memory, such as the system kernel, process, external device status and network status . Because the data in this directory is in memory, so it does not occupy any hard disk space! More important documents such as/proc/cpuinfo,/PROC/DMA,/proc/interrupts,/proc/ioports,/proc/net/*, etc.
/sys This directory is very similar to/proc, but also a virtual file system, which is also a key to recording kernel-related information . This includes the kernel modules currently loaded and the hardware device information detected by the kernel. 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 is related to boot, only the root directory will be mounted during the boot process, and the other partitions will continue to mount after the boot is completed. Directories associated with the switching process in the root directory cannot be placed in different partitions from the root directory. As in the following directories:

/etc: Configuration file

/bin: Important Execution files

/dev: Required device files

/lib: Function libraries required to execute files and modules needed by the kernel

/sbin: Important System Execution files

2. The meaning and content of/usr

According to the basic meaning of FHS, the data placed in/USR is shareable and immutable, and USR is the abbreviation for UNIX software resource, which is the directory placed by the UNIX operating system software resource, not the user's data. All system default software (software provided by distribution Publishers) is placed under/usr.

  

Directory File contents should be placed
/usr/x11r6 For the X Window System important data placed in the directory, the reason is named X11R6 because the last X version of the 11th version, and this version of the 6th release of the meaning
/usr/bin/ Most of the users can use the command to put it here. Notice the difference between it and the/bin (whether it is related to the boot process)
/usr/include The header file and the include file (include) in the program language such as C + +, when we install some data in the Tarball Way (*.tar.gz), we use many of the included files inside
/usr/lib A library of libraries, target files (object file) for each application, and executable files or scripts (script) that are not commonly used by the general user. Some software provides special commands to set up the server, which are not often operated by the system administrator, and will be placed in this directory. Note that if you are using a x86-64 Linux system, there may be/usr/lib64 Mulan generated
/usr/local The system administrator installs its own downloaded software (non-distribution default provider) on the machine, and recommends installing to this directory, which is easier to manage. /usr/local, this directory is also a subdirectory with Bin,etc,include,lib
/usr/sbin System commands that are required for non-system normal operation. The most common are service commands for some Web server Software (daemon)
/usr/share

Where the shared files are placed, the data placed in this directory is almost always readable by the hardware architecture, because almost all of them are common in the directory of text files again, and these subdirectories are:

A./usr/share/man: Re-line Help file

B./usr/share/doc: Description of software miscellaneous documents

C./usr/share/zoneinfo: Time zone files related to time zones

/usr/src General source code is recommended to place here, as for the kernel source code is recommended to be placed in the/usr/src/linux/directory

  3. The meaning and content of/var

If/usr is a directory that occupies a larger hard disk capacity during installation,/var is a directory that will gradually take up hard disk capacity after the system is running. Because the/var directory is primarily for files with normal changes, including cache, login files (log file), and files generated by some software operations, including program files (lock file, run file), or such as MySQL database files.

    

    

Directory File contents should be placed
/var/cache Some of the staging files that are generated during the run of the application itself
/var/lib The program itself executes the process that needs to be used to place the data file in the directory. In this directory the respective software should have its own directory. For example, the MySQL database is placed in/var/lib/mysql/, and the RPM database is placed in the/var/lib/rpm directory
/var/lock Some devices or file resources can only be used by one application at a time, if there are two programs using the device, there may be some error conditions, so you have to lock the device (lock), to ensure that the device will only be used for a single software
/var/log This is the directory where the login file is placed. More important documents inside such as/var/log/messages,/var/log/wtmp (log the information of the login), etc.
/var/mail The directory where personal e-mail is placed, but this directory is also placed in the/var/spool/mail/directory. Typically, these two directories are inter-connection files.
/var/run After some programs or services are started, their PID will be placed in this directory.
/var/spool This directory usually places some data on columns, so-called "queues" are data that is queued for use by other programs, which are usually deleted after being used. For example, the system receives a new new piece that will be placed in the/var/spool/mail, but the letter will be deleted in principle after the user has received the letter. If the letter is not sent out temporarily, it will be put into the/var/spool/mqueue, and then deleted after being sent out.

4. Directory tree

Under Linux, all files and directories start with the root directory. That is the source of all directories and files. Then one more branch down, a bit like a twig. So we also call this directory Configuration "directory tree", its main features are:

A. The starting point of the directory tree is the root directory (/,root)

B. No directory can use only the local file system, or the file system on the network. For example, you can use the network File System (NFS) server to mount a specific directory, and so on.

C. Each file name in this directory tree (including the full path) is unique

    

5. CentOs View

Uname-r----------> can see the actual kernel version

Lsb_release-a--------> View versions of LSB and distribution

  

 

Linux Directory Configuration

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.