Introduction to the Linux system directory structure

Source: Internet
Author: User
Tags system log

Reference blog: http://www.cnblogs.com/chensiqiqi/p/6243549.html Thank Yumbo Lord for learning Linux for me to specify the direction!!

Linux directory: Everything starts with "root", "/" is the starting point of all directories (fixed point)

Linux each directory can be mounted on a different device (disk).

Logically all directories (including subdirectories under the directory) are at the highest level of directory "/", The root ("/") directory is the starting point of all directories in the Linux system (a little bit), the directory below the root and the subdirectory of the directory is a hierarchical tree structure, much like a hanging upside down a tree, This is different from the directory structure that the Windows system splits according to the hard disk partition (C:d:e:) (the Windows system can be understood as multiple trees, and each partition is a separate small tree).
These different directories in the Linux system are also very special, different directories can be distributed on different hard disk partitions and different hard disk devices, which is difficult for Windows system, the different partitions of Windows system are independent.

Linux under the device is not to see the entrance, no window no way to the prison, if you want to access the equipment must have an entrance, the entrance is a mount point, mount Point is the essence of the directory

All directory content in a Linux system is organized by category. For example, the application under Linux, its executable program may be in/usr/bin, and its data files and help under/usr/share, the runtime loads the configuration file and the service start command under/etc/.

Summary of Content

    1. All directories of the Linux system are a hierarchical inverted tree-like structure, andthe "/" root is the vertex of all directories.
    2. Different directory data can span different disk partitions or different disk devices
    3. All directories are organized and named according to a certain category

historical allusions to the UNIX system directory structure

Tip : Learn the historical story of the directory structure to give you a clear understanding of the directory structure of Linux.

1969, Ken Thompson and Dennis
Ritchie invented Unixon a minicomputer PDP-7. In 1971, they upgraded the mainframe to PDP-11.

At the time, they used a storage disk called RK05, which was about 1.5MBin size.

Because the capacity of the hard disk is very small, so long, the operating system storage disk data (root directory) has become more and more large, resulting in a disk can not fit the data. As a result, they added a second set of RK05, and made provisions, the first disk dedicated to storage System program related, the second disk dedicated to the user's own program, so the mount directory point named/usr. That is, the root directory "/" is mounted on the first disk, and the "/usr" directory is mounted on the second disk . In addition, the other directory structure of the two disks is identical, for example: the first disk directory (/bin,/sbin/lib/tmp ... ) is re-present in the/usr directory (/bin,/sbin,/lib)

tmp idea: do not delete things easily, can be placed under the TMP directory. Deleted after 1 months.

Time is not long, the second storage disk is full, they have to add a third set of RK05, the directory is named Home/home, and do the provisions,/USR for the user's program,/home for storing the user's data.
Since then, the naming and definition of this directory structure has continued. With the development of equipment, the capacity of the hard disk is also more and more large, then the meaning of each directory has been further clarified.

Linux directory Structure

Directory hierarchy Standard FHS

    • FHS Full Name (Filesystem Hierarchy standard), Chinese meaning is the directory hierarchy Standards , is the Linux directory specification standard.
    • Click to view more
    • FHS defines the two-tier specification :
    • The first layer : the "/" directory should be placed in each directory of the file data , such as:/etc Directory placement system configuration files, such as:/etc/exports,/etc/hosts, and/bin and/sbin placement programs and system commands.
    • second tier : is for/ usr(Unix software resource| Secondary hierarchy) and/ var(Variable data) are defined as subdirectories of the two directories. Example: Placing system log files under/var/log, etc.
    • Tip:the/var partition is separate and the hard drive is large enough. We all have surveillance, the remaining 20% alarms .

The directory structure of the Linux system is "/" at the top, and all directories start from the root. We can get the directory structure under the root (/) through the tree command.

Summary: Important catalogue Review
    • /dev Device Directory
    • /etc/System Configuration and service configuration file , service startup command directory/ETC/INIT.D
    • /proc virtual file system showing kernel and process information
    • /tmp temp file directory,
    • /home directory for ordinary users
    • /root Super Admin Home Directory
    • /var changes the directory , typically the log file (/var/log), the cache directory. /var/log/messages,/var/log/secure
    • /USR user programs and data, Help files, binary commands, etc. directory (usr/local/)
    • /Bin directory for general user commands
    • /sbin and/usr/sbin/: Directory of Super User commands
Important Sub-directory description

Knowledge of the Linux directory path that must be mastered

Modifying the network card configuration file

    • Etc/sysconfig/network-scripts/ifcfg-eth0
    • View Eth0 (second block of eth1)
    • Modify the NIC configuration by setup===> "Network Config" to change this file.
    • Fixed IP address
    • Restart NIC/etc/init.d/network Restart (affects all network cards)
    • Ifdown eth0 && ifup eth0 only for eth0 NIC

Attention

    • The setup file Ifcfg-interface-name contains most of the detailed information needed to initialize the interface. Where Interface-name will be based on the type of network card and sorting, the general name is ETH0,ETH1,PPP0, wherein the ETH represents an Ethernet (eth0) type of network card, 0 means the first NIC, 1 means the second NIC, The ppp0, however, represents the first Point-to-poirt protocol a network interface. Defined in the Ifcfg file
      Items depend on the interface type.
      The following values are more common:
    • Device=name, where name is the physical device name
    • IPADDR=ADDR, where addr is the IP address
    • Netmask=mask, where mask is the network mask value
    • GATEWAY=ADDR, where addr is the gateway address
    • Onboot=answer, where answer is yes (activates the device at boot time) or no (does not activate the device at boot time)
    • Userctl=answer, where answer is yes (non-root user can control the device) or no
    • Bootproto=proto, where Proto takes one of the following values: None, no protocol at boot, static statically assigned address, BOOTP, using BOOTP protocol, or DHCP, using DHCP protocol

The settings are actually modified by/etc/resolv.conf this file

[Email protected] ~]$ cat/etc/resolv.conf; Generated By/sbin/dhclient-scriptsearch localdomain zhangnameserver 8.8.8.8nameserver 202.106.0.20[[email protected] ~]$

Summary

1, the Linux client DNS can be set in the network card configuration file (Ifcfg-eth0)

2,Linux client DNS can also be set in the/etc/resolv.conf

3, the network card settings DNS precedence over/etc/resolv.conf, if you restart the network card DNS will overwrite the/etc/resolv.conf settings
4,/etc/hosts: Set the User IP and first name (domain name) corresponding parsing table, equivalent to the local LAN LAN DNS resolution file
5,/etc/sysconfig/network: Can modify the hostname and network card start, gateway and other configuration. To change the hostname permanently, you need to modify the following two items at the same time:
(1) Vi/etc/sysconfig/network
(2) Hostname host name

Important directories and files under the/etc/directory
    • /etc/issue (/etc/issue.net): Records information such as the system version displayed before the user logs in
    • /ETC/MOTD: Login Reminders (anything written inside will show up before all users log in)
    • /etc/redhat-release: Includes a line that declares the Redhat version number and the name of the information.
    • /etc/group: Set the user's group name and related information
    • /ETC/PASSWD: User account information file
    • /etc/shadow: User password information file
    • /etc/gshadow: Group Password file
    • /etc/sudoers: Can execute configuration file with sudo command (privilege elevation)
    • /etc/securetty: Set which interrupts allow root login
    • /etc/login.defs: Default configuration When all users log on
    • /ETC/MODPROBE.CONF: Additional parameter settings for kernel modules
    • /etc/rsyslog.conf: Log settings file (centos6.x only)

Linux will execute the contents of the/etc/rc.local once it is powered on.

Other catalogs
    • /lib: Library of functions to be used by the system
    • Related modules of/lib/modules:kernel
    • /VAR/LIB/RPM:RPM Kit Installation Place
    • /usr/bin: This directory is a directory of executable programs, and when we install a program from a package that comes with the system, most of his executables are placed in this directory.
    • LIB64: library file storage Directory
    • /usr/sbin: This directory is also a directory of executable programs, but most of them contain commands related to system administration; similar directories are/sbin or/usr/local/sbin or/usr/x11r6/sbin, etc.;
    • /usr/local: This directory is generally used to store the user's self-compiled installation software directory, usually through the source package installed software, if not specifically designated installation directory, is generally installed in this directory.
    • /usr/local/bin: User-installed small applications, and some symbolic connections for large applications in the/usr/local directory
    • /usr/local/sbin: System Global Environment directory, you can put some scripts that do not need to add path execution
    • /usr/share: Things that the system uses to store, such as/usr/share/doc and/usr/share/man Help files
    • /usr/src: Kernel Source storage directory, such as the following kernel source directory, such as linux,linux-2.xxx.xx directory.

1,RPM-IVH (when there are RPM packages and Yum is not available)
2,yum Install
(Habits: Online servers rarely install Apache,nginx,mysql, functional software will use Yum)
3, source code (./configure,make,make install), custom. Important services for large and medium-sized enterprises.
Portal: Source---Customized RPM package---making yum warehouse----Yum Installation

    • /usr/bin: Binary file directory that can be executed by the user
    • /usr/local/bin: Binary file directory that can be executed by the user
    • /usr/lib: Library of functions to be used by the system
    • /usr/local/lib: Library of functions to be used by the system

Path knowledge under the/var directory
    • /var: log file
    • /var/log: Various system log storage location
    • /var/log/messages: System Information default log file, very important . Automatic round-robin by week
    • /var/log/secure: Records log in to the system access information files, weekly automatic round robin, for example: Pop3,ssh,telnet,ftp will be recorded here. System-Safe log files.
    • /var/spool: Default path for timed tasks, files named by user name (/var/spool/cron/root)
    • Var/spool/clientmqueue:sendmail temporary mail file directory, there are many reasons for this directory is a lot of broken files, such as crontab timed task commands do not add >/dev/null and so on. Work occasionally because of the directory file too much, the number of partition Inode in/var is exhausted, unable to write to the file (centos6.x will not install SendMail, so there is no problem)

The important path knowledge under the/proc

Top: See CPU, etc.

    • /proc: Virtual directory, the virtual file system directory for memory mapping, kernel and process
    • /proc/version: Kernel version
    • /proc/sys/kernel: System kernel function
    • /proc/sys/net/ipv4: Temporary effect when modifying the configuration of the Proc.
    • (The configuration in the/etc/sysctl.conf kernel parameter is permanent.) The effect of two paths is the same. Net.ipv4.tcp_tw_reuse=1 is actually modifying the content of/proc/sys/net/ipv4/tcp_tw_reuse)
    • /proc/cpuinfo: Information about the processor, such as type, manufacturer, model and performance, etc.
    • /proc/meminfo: System memory information,free-m
    • /proc/devices: List of all devices configured by the current running kernel
    • /PROC/DMA: DMA channel currently in use
    • /proc/filesystems: The file system configured by the current running kernel
    • /proc/initerrupts: The interrupt being used, and how many interrupts were there.
    • /proc/ioports: The I/O port that is currently in use.
    • /PROC/LOADAVG: System load average information (System busy situation, more accurate, but not enough detailed system performance indicators), uptime results. (Load values do not exceed the number of cores of the CPU.) See Load Top,uptime,w)

    • /proc/mounts: Device mount information, df-h similar

Paths and documents that must be mastered
    • /etc/sysconfig/network-scripts/ifcfg-eth0 (first NIC configuration file)
    • /etc/resolv.conf (DNS configuration file, Nic profile priority resolv.conf)
    • /etc/hosts (IP and domain name (hostname) Resolution table)
    • /etc/sysconfig/network (host)
    • /etc/fstab (Boot auto mount list)
    • /etc/rc.local (boot from boot file, self-boot command, script)
    • /etc/inittab (Linux boot Run level profile)
    • /ETC/INIT.D (Service startup command script directory)
    • /etc/profile (Global environment variable)
    • /ETC/BASHRC (alias)
    • /usr/local (compile and install the software default installation directory)
    • /var/log/message (System log)
    • /var/log/secure (System security log)
    • /var/spool/cron/root (scheduled task, root directory)
    • /proc/cpuinfo (System CPU information)
    • /proc/meminfo (System memory information)
    • /PROC/LOADAVG (System CPU load level)
    • /proc/mounts(System mount information)
Discussion: Under what circumstances is the CPU load very busy?

When the average CPU load rate is greater than the number of cores of the CPU, we can say that the load on the server CPU is already busy.

Introduction to the Linux system directory structure

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.