Linux system--file directory

Source: Internet
Author: User
Tags uuid

Linux file directory

When we use the Linux system, we will find a lot of directories, these directories also have a lot of subdirectories and files. Because of the many Linux development teams and individuals, if everyone in accordance with their own ideas to configure file placement directory, then for the personal use and management will be a great problem.
In this case, the advent of FHS makes Linux users and developers have a standard for managing file systems, the FHS standard (Filesystem Hierarchy). FHS the directory is defined as four interactive forms, depending on whether the file system is frequently used or not, and if the user is allowed to change it arbitrarily:

available for sharing Non-shareable
Immutable /usr (software placement) /etc (config file)
Immutable /OPT (third-party software) /boot (boot with kernel file)
can be changed. /var/mail (user email) /var/run (program-related)
can be changed. /var/spool/news (News Group) /var/lock (program-related)

1. Shareable: can be shared to other systems mount the use of the directory, so including the execution of files and users of the mail, etc., 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. such as function libraries, file description files, host service profiles managed by system administrators, etc.
4. Volatile: frequently changing data, such as log-in files, newsgroups that the general user can accept themselves

Root directory/

All directories are attached to the directory, and the root directory is related to actions such as boot/restore/system repair.
FHS Standard Recommendation: The root directory (/) should be the smaller the partition slot should be as small as possible, and the application installed software should not be placed in the same partition with the root directory, keep the root directory smaller the better

  • /bin: The system has a lot of directories to place execution files, but/bin is special. Because/bin places instructions that can be manipulated in single-person maintenance mode. The commands under/bin can be used by root and general account, mainly: Cat, chmod, chown, date, MV, mkdir, CP, Bash and so on.

  • /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: Vmlinuz, if you are using grub this boot manager, there will be/boot/grub/this directory Oh!

  • /dev: On Linux systems, any device or interface device exists in this directory in the form of a file. All you have to do is access a device by accessing one of the files under the directory-/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 start of various services, and so on. In general, the file attributes in this directory can be viewed by the general user, but only root has the power to modify them. FHS It is recommended that you do not place executable files (binary) in this directory. The more important files are:/etc/inittab,/etc/init.d/,/etc/modprobe.conf,/etc/x11/,/etc/fstab,/etc/ sysconfig/and so on. In addition, the following important directories are:

    • /etc/init.d/: The preset startup script for all services is placed here, for example to start or close iptables:/etc/init.d/iptables start,/etc/init.d/iptables stop

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

    • /etc/x11/: Various configuration files related to x Window are here, especially xorg.conf this x Server configuration file

    • /ETC/MOTD: Configure the display information after successful login

  • /home: This is the default user home directory for the system. When you add a generic user account, the default home directory will be the norm.

  • /lib: The function Library of the system is very much, and the/lib place is the function library that will be used at boot, and the function library that the instruction under/bin or/sbin will call. What is a function library? You can think of him as a "plug-in", some instructions 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 places the core-related modules (drivers)

  • /media Media: The English language of the medium, as the name implies, this/media is placed under the removable device. including floppy disk, CD-ROM, DVD and so on are temporarily mounted here. Common file names 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.

  • /opt This is a directory for third-party software placement. What is third party collaboration software? For example, the KDE desktop Management system is a standalone program, but it can be installed on a Linux system, so KDE software is recommended to be placed in this directory. Also, if you want to install additional software on your own (not provided by the original distribution), you will be able to install your software here as well. However, in the previous Linux system, we are still accustomed to place in the/usr/local directory!

  • /root: The home directory of the system administrator (root). This is because if you go into single-player maintenance mode and only mount the root directory, the directory can have root home directory, so we would like Root home directory and root directory in the same partition slot.

  • /sbin:linux has a lot of instructions for setting up the system environment, which only the root can use to "set up" the system, the other users can only be used to "query". Placed under the/sbin for the boot process required, which includes the boot, repair, restore the system required instructions. As for some server software programs, they are generally placed in/usr/sbin/. As for the system binaries generated by the natively installed software, it is placed in the/usr/local/sbin/. Common directives include: fdisk, fsck, Ifconfig, Init, mkfs and so on.

  • /srv:srv can be regarded as the abbreviation of the service, which is the data directory to be used after some network services are started. Common services such as WWW, FTP, and so on. For example, the Web page data required by the WWW server can be placed inside the/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 can not be placed in this directory Ah! Because FHS even suggested that when the boot, you should be the/TMP data are deleted! Common areas that are available to all users.

  • /proc: When the operating system is running, process information and kernel information (CPU memory) are stored here. The data he places are in memory, such as the system core, travel information (process), peripheral device status and network status, etc. 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/* and so on.

  • /lost+found: The system crashes unexpectedly. The file fragment will be generated and the system will check the directory when it restarts. Put some missing fragments into this directory, this directory will usually exist at the top of the partition slot, such as you add a hard disk in the/disk, then in this system will automatically generate a directory such as "/disk/lost+found"

Directories that cannot be separated from the root directory (related to the boot process):

The root directory is related to power-on, only the root directory will be mounted during the boot process, and the other slots will continue to mount after the boot is complete. Because of this, therefore, the root directory and the boot process related directories, it is not able to be placed with the root directory of different slots to go!

/etc: Configuration file
/bin: Important Execution file
/dev: Required device files
/lib: Function libraries required for execution of files and modules required by the core
/sbin: Important System Execution files

  • /usr:
    1. According to the basic definition of FHS, the data placed in/USR is shareable and immutable (shareable, static), and if you know how to mount the slots through the network,/USR can indeed be shared with other hosts within the local area network!
    2.usr (Unix software Resource, UNIX operating system software Resource) FHS recommends that all software developers should place their data reasonably in the sub-directory under this directory, rather than building the software's own separate directory.
    3. All system default software (software provided by distribution Publishers) is placed under/usr, so this directory is somewhat similar to the C:\Windows\ + C:\Program files\ of the Windows system, the combination of the two directories, When the system has just been installed, this directory will occupy the most hard disk capacity.

    • /usr/x11r6/for the X Windows system important data is 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 instructions are placed here! Please note the difference between him and/bin. (whether it is related to the boot process)

    • /usr/include/c/c++ and other programming languages such as the header and the containing file (include), when we install some data in tarball way (*.tar.gz way), we will use a lot of included files inside!

    • The/usr/lib/contains the function libraries for each application, the object file, and the execution file or script that is not commonly used by the general user. Some software will provide some special instructions for the server settings, these instructions will not be frequently operated by the system administrator, it will be placed in this directory. Note that if you are using a x86_64 Linux system, there may be/usr/lib64/directory generation

    • /usr/local/system administrators install their own downloaded software (not the distribution default provider) natively, it is recommended to install to this directory, which is easier to manage. For example, your distribution provides older software, You want to install newer software but do not want to remove the old version, at this time you can install the new version of the software in the/usr/local/directory, can be different from the original version of the software! You can go to the/usr/local yourself to see, the directory is also has bin, etc, include, Lib ... 's Secondary directory.

    • /usr/sbin/system directives required for non-system normal operation. The most common is the service instructions for some Web server Software (daemon)

    • /usr/share/places the shared files, the data placed in this directory is almost the data that can be read from the hardware architecture.
      Because it's almost all text files! These secondary directories are common in this directory:/usr/share/man: Online Help files
      /usr/share/doc: Software Miscellaneous file Description/usr/share/zoneinfo: Time zone-related timezone file

    • /usr/src/General source code is suggested to be placed here, SRC has the meaning of source. As for the core source code, it is recommended to place it in the/usr/src/linux/directory.
  • /var
    The directory is primarily for files with normal changes, including cache, log file, and files generated by certain software operations, including program files (lock file, run file), or files such as MySQL databases. This is why/var will gradually take up the HDD capacity after the system has been operated.

      • /var/cache/Some of the temporary archives that are generated during the operation of the application itself.

      • The/var/lib/program itself executes the process that needs to be used to place the data files in the directory. In this directory, the respective software should have its own directory.
        For example, the MySQL database is placed in the/var/lib/mysql/and the RPM database is put into/var/lib/rpm!

      • /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 it is necessary to lock the device (lock), to ensure that the device will only be used for a single software. For example, the recorder is burning a disc, do you think, there will be two people at the same time using a burner burning tablets? If two people were recording at the same time, whose data was written by that film? So when the first person is burning the burner is locked and the second person has to be unlocked (that is, the previous person ran out) to continue using it.

      • /var/log/important to Not! This is the directory where the login files are placed! There are more important documents such as/VAR/LOG/MESSAGES,/VAR/LOG/WTMP (log in information) and so on.

      • /var/mail/the directory where personal e-mail is placed, but this directory is also placed in the/var/spool/mail/directory! Usually the two directories are linked files for each other!

      • /var/run/Some programs or services are started, their PID will be placed in this directory Oh! As for the meaning of PID, we will refer to it in subsequent chapters.

      • /var/spool/This directory usually places some queue data, so-called "queues" are queued to wait for other programs to use the data! This data is usually deleted after it is used. For example, the system receives a new letter 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, it will be put into the/var/spool/mqueue/. It is deleted when it is sent out. If it is a work schedule data (crontab), it will be placed in the/var/spool/cron/directory!

Important Sub-directories

1./etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 name of the set
Hwaddr=00:1e:67:65:db:d7mac Address
Type=ethernet Network Type
Uuid=3096d6ad-e53b-42cc-a385-8c906af05cae Nic Unique identification
Onboot=yes boot up
Nm_controlled=yes
Bootproto=none Start protocol (DHCP none static)
Dns2=
dns1=
Ipv6init=no
Userctl=no
ipaddr=172.29.77.107
netmask=255.255.255.0
gateway=

[Email protected] sbin]# blkid/dev/sda2:uuid="5e7032c8-8d86-41b9-807f-9c9770d06e35" TYPE="Ext4"/dev/sda1:uuid="ec3216ee-4bab-4f13-85c2-7fe73126c883" TYPE="Ext4"/dev/sdb1:sec_type="Msdos"Uuid="70ce-b93f" TYPE="VFAT"/dev/sdb2:uuid="34cf2f70-1081-452e-bc39-0d2a38d9233d" TYPE="Ext4"/dev/sdb3:uuid="F67F5156-40C6-482B-8929-01D3A094D8CF" TYPE="Swap"/dev/sdb4:uuid="116c6469-f295-493d-aed1-af53327bc820" TYPE="Ext4" 

2./etc/resolv.conf

DNS configuration file (This configuration file must have DNS information in order to surf the internet)
The DNS setting in the network card takes precedence over the DNS of the resolv.conf setting, and if the NIC is restarted, the network card's DNS settings override the/etc/resolv.conf settings.

[root@localhost sbin]# cat /etc/resolv.conf172.22.21.28.8.8.8

/etc/init.d/network Restart restart all network cards
Ifup/ifdown Ifcfg-eth0 reboot to close a NIC

[Root@localhost~]# Netstat-an|grep 172Tcp0      the 172.29.77.107: A            172.28.77.38:57971          establishedTcp0      0 172.29.77.107: A            172.28.77.38:49440          established

3./etc/hosts

4./etc/sysconfig/network
Hostname configuration file hostname

[root@hcy ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=localhost.localdomain

Reference Links:
Http://blog.chinaunix.net/uid-9525959-id-2001812.html
http://www.iteye.com/topic/1125162
Http://www.cnblogs.com/JCSU/articles/2770249.html recommended

Linux system--file directory

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.