Linux directory structure and detailed introduction

Source: Internet
Author: User
Tags aliases log log syslog system log

/: root directory, located at the top level of the Linux file system directory structure, the general root directory is only the directory, do not store files, etc,/bin,/dev,/lib,/sbin should and root directory placed in a partition.

/bin,/usr/bin: This directory is a command file directory, also known as a binary directory. Contains important Linux commands and binary (executable) files for system administrators and ordinary users, including shell interpreters, and so on.

/ Boot: This directory contains the kernel and boot loader files for the system,/boot/vmlinuz the kernel files for Linux, and/boot/gurb. A separate partition is recommended, with a partition size of 100M.

/ dev: Device file directory, storing the device files under the Linux system, accessing a file in that directory, equivalent to accessing a device, storing the corresponding files attached to a device (terminal, disk drive, optical drive, network card, etc.) connected to the computer. including character devices and block devices, commonly used is mounted CD-ROM mount/dev/cdrom/mnt.

/ etc: the directory where the system configuration file is stored, which holds most of the system's configuration files and subdirectories, does not recommend storing executable files in this directory, important configuration files are/etc/inittab,/etc/fstab,/ETC/INIT.D, etc /X11 (related to X window System),/etc/sysconfig (network-related),/etc/xinetd.d remember to back up before modifying the configuration file. The files in this directory are used by the system administrator, and the normal user has read-only access to most of the files.

/home: The system Default User host directory, when adding user account, the user's host directory is stored in this directory, ~ represents the current user's host directory, ~test represents the user test's host directory. It is recommended that you separate partitions and set up large disk space to allow users to store data.

/lib,/usr/lib,/usr/local/lib: The directory of the library used by the system, the program in the execution process, need to call some additional parameters when the function library to assist, the directory is stored in a variety of programming language library. A typical Linux system contains library files in C, C + +, and Fortran languages. The library image file under the/lib directory can be used to start the system and execute commands, the directory/lib/modules contains the loadable kernel modules, the/lib directory holds all the important library files, and the other library files are mostly stored in the/usr/lib directory.

/lost+fount: In the EXT2 or EXT3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. During system startup, the Fsck tool checks here and repairs the corrupted file system. Sometimes problems with the system, a lot of files are moved to this directory, may be repaired by manual method, or move the file to the location of the shipment

/mnt,/media: The MNT directory is primarily used to temporarily mount file systems, providing default mount points for some devices, such as Floppy,cdrom. This way, when a device such as an optical drive is mounted, it is possible to access the files on the corresponding CD-ROM by accessing the files under directory/mnt/cdrom.

/opt: A directory for the host to install additional software. For example: The Fedora Community development software used by FC4, if you want to install new KDE desktop software yourself, you can install the software in this directory. In previous Linux systems, it was customary to place them under the/usr/local directory.

/proc: This directory data are in memory, such as system core, external device, network status, because the data are stored in memory, so do not occupy disk space, the more important directory has/proc/cpuinfo,/proc/interrupts,/proc/ DMA,/proc/ioports,/proc/net/*, and so on.

/root: The host directory of the system administrator root, the first boot partition of the system is/, so it is best to place/root and//in a partition.

/sbin,/usr/sbin,/usr/local/sbin: Place executable commands that the system administrator uses, such as Fdisk, Shutdown, Mount, and so on. Unlike/bin, these directories are commands for the root of the system administrator, and the average user can only "view" and not be set up and used.

/ tmp: the directory where files are temporarily stored by the general user or the program being executed, accessible to anyone, and important data cannot be placed in this directory.

/srv: The data directory that needs to be accessed after the service starts, such as the Web page data that the WWW service needs to store within/SRV/WWW.

/usr: application storage directory,/usr/bin storage application, /usr/share store shared data,/usr/lib storage can not directly run, but is a lot of programs to run the necessary library files ,/usr/local storage software upgrade package,/usr/share/doc system description file storage directory.

/usr/share/man: The program description file directory, the use of man LS will query/usr/share/man/man1/ls.1.gz content recommended separate partition, set a larger disk space.

/var: Place files that change frequently during system execution, such as log file/var/log that change at any time. /var/log/message: All login files are stored in the directory. /var/spool/mail: The directory where the mail is stored. /var/run: After a program or service is started. It is recommended to separate partitions to set large disk space.

/ tmp: Store temporary files directory, some commands and applications will be used to this directory. All files in this directory are deleted periodically to prevent temporary files from filling up the entire disk.

/dev Directory

DEV is the acronym for Devices. /dev This directory is important to all users. Because this directory contains all the external devices used in the Linux system. But this is not the driver for the external device, which is not the same as the Windows,dos operating system. It is actually a port that accesses these external devices. We can easily access these external devices, and access a file without any difference in a directory.

Linux inherits the Unix style, recognizing all devices as a file.

There are two types of device files: block device files (b) and character device files (c), device files are generally stored in the/dev directory, and common device files are described as follows:

/dev/hd[a-t]:ide Equipment

/DEV/SD[A-Z]:SCSI Equipment

/DEV/FD[0-7]: Standard floppy drive

/DEV/MD[0-31]: Soft RAID device

/DEV/LOOP[0-7]: Local loopback device

/DEV/RAM[0-15]: Memory

/dev/null: Unlimited data reception device, equivalent to black hole

/dev/zero: Unlimited 0 Resources

/DEV/TTY[0-63]: Virtual terminal

/DEV/TTYS[0-3]: Serial port

/DEV/LP[0-3]: the same port

/dev/console: Control Console

/dev/fb[0-31]:framebuffer

/dev/cdrom =/dev/hdc

/dev/modem =/dev/ttys[0-9]

/dev/pilot =/dev/ttys[0-9]

/dev/random: Random number devices

/dev/urandom: Random number devices

/etc Directory

/ETC/RC,/ETC/RC.D,/ETC/RC*.D the directory where the scripts or scripts runs when the run level is started or changed.

/etc/passwd User database, where the domain gives the user name, real name, home directory, encrypted password, and other information of the user.

/etc/fstab the file system list of the Mount-a command (in/ETC/RC or equivalent startup file) that is automatically mount at startup. Linux, also includes information about the swap area enabled with SWAPON-A.

/etc/group is similar to/etc/passwd, but it does not explain the user but the user group.

/etc/inittab init configuration file that sets the system to what runlevel the init process will set when the system starts.

/etc/issue Getty The output information before the logon prompt. Typically, a short description of the system or welcome information is determined by the system administrator.

/ETC/MOTD Message of the day, automatic output after successful login is determined by the system administrator and is often used to advertise information, such as a warning to schedule shutdown time.

/etc/mtab A list of currently installed file systems. Initialized by scripts and automatically updated by the Mount command, requires a list of currently installed file systems, such as the DF command.

/etc/shadow The shadow password file on the system on which the shadow password software is installed. The shadow password file moves the encrypted password in the/etc/passwd file to the/etc/shadow, and the latter is only readable by the root, which makes it more difficult to decipher the password.

/etc/login.defs The login command configuration file.

/etc/printcap is similar to/etc/termcap, but differs for printer syntax.

/etc/profile,/etc/csh.login,/ETC/CSH.CSHRC The file that is executed at logon or startup Bourne or C shells, which allows the system administrator to establish a global default environment for all users.

/etc/securetty confirm the secure terminal, which terminal allows root login. Typically only virtual consoles are listed, which makes it impossible (at least difficult) to break into the system via modem or network and gain superuser privileges.

/etc/shells the list of trusted SHELL.CHSH commands allows the user to change the login shell within the scope specified in this file. Provides a service process for a machine FTP service FTPD Check that the user shell is listed in the/etc/shells file. If it is not, the user will not be allowed to log on.

/etc/sysconfig Network configuration related directory

/etc/dir_colors Setting the color

/etc/hostname Setting the user's node name

/etc/networking Only yes indicates network presence

The /etc/host.conf file describes how the user's system queries the node name

/etc/hosts Set the user's own IP and name corresponding table

/etc/hosts.allow settings allow use of inetd machines

/etc/hosts.deny settings are not allowed for use with inetd machines

/etc/hosts.equiv setting remote machine without password

/etc/inetd.conf Setting the configuration of the System network daemon inetd

/etc/inetd.pid inetd Process ID for this process

/ETC/HOSTS.LPD Set which nodes at the far end can use native printers

/etc/gateways setting up the router

/etc/protocols Setting System-supported protocols

/etc/named.boot Setting the configuration file for the name server

/etc/named.pid The process ID of the name server running on this machine

/etc/networks Setting the network configuration file

/etc/resolv.conf Setting the name server of the system

/etc/services Set the end product and protocol type of the system and the services provided

/etc/exports to set up NFS systems

/etc/nntp_inews_domain Setting up a news server's configuration file

/etc/nntpserver Setting the address of the news server used by the user

/etc/xf86config X Window's configuration file

A hardware ID unique to the /etc/hostid system

/etc/at.deny Set which users cannot use the AT command

/etc/bootptab The format of different device driver files to the Makedev program

/etc/makedev.cfg settings file for Makedev as with DevInfo

/etc/diphosts Setting the user name and password for the dial-up server

/etc/slip.hosts,/etc/slip.login Setting the Slip profile

/etc/fastboot using Shutdown-f, reboot the system to check this file.

/etc/fstab Record the file system to mount on boot

/etc/ftpaccess Some configuration of the FTP server

/etc/ftpconversions Setting the location of the filter used in FTP

/etc/ftpusers Setting users who cannot use the FTP service

/etc/ld.so.cache Find cache for system dynamic link libraries

Path to the /etc/ld.so.conf system dynamic Link library

/etc/lilo.conf Lilo configuration file

/etc/magic used for the file command.

/etc/aliases files used by SendMail to set aliases

/etc/mail.rc,

/etc/mailcap,

/ETC/SENDMAIL.CF,

/Etc/sendmail.st Set the SendMail

/ETC/MOTD where a super user posts notifications

/etc/organization Store user's name and organization

/etc/pnpdevices List of supported Plug&play devices

/etc/snooptad Monitor User's screen, monitor the terminal list

/etc/sudoers can be the sudo command configuration file

/etc/syslog.conf System Logger SYSLOGD configuration file

/ETC/UTMP currently using the system user information

/etc/wtmp is similar to utmp, but it accumulates.

/etc/nologin system does not want the user to log on when shutdown, this file is generated

/etc/termcap Setting the system terminal information

/etc/ttys setting the terminal type of the system

/etc/gettydefs Getty_ps's definition file

/etc/yp.conf configuration file for NIS

/etc/mtools.conf setting parameters of the Mtools program

/ETC/FDPRM setting parameters for formatted floppy disk

/etc/login.access files that control user logon rights

/proc Directory

/proc/cmdline The relevant parameters when loading kernel, consult this file to see how the system is started.

/proc/cpuinfo Information about the CPU of this machine, including the time pulse, type and arithmetic function, etc.

/proc/devices This document records the main device codes for each major device in the system, and is related to Mknod.

/proc/filesystems Current system has been loaded by the file system.

/proc/interrupts The IRQ assignment status above the current system.

/proc/ioports The I/O addresses configured for each device on the current system.

/proc/kcore This is the size of the memory, but do not read him.

/proc/loadavg Remember top and uptime? Yes, the top three average values are recorded here.

/proc/meminfo uses the memory information listed in free, which is also available here.

/proc/modules Currently our Linux has loaded a list of modules that can also be thought of as drivers.

The data that is already mounted on the /proc/mounts system is the data that is called with the Mount command.

/proc/swaps What is the memory where the system hangs and loads? The use of partition is recorded here.

/proc/partitions Use fdisk-l will appear all the partition right now? There are also records in this document.

/proc/pci on the PCI bus, the details of each device can be consulted by LSPCI.

/proc/uptime is the information that appears when you use uptime.

The /proc/version core version is the content displayed with Uname-a.

/proc/bus/* Some of the bus line device, as well as a U disk device is also recorded here.

/usr Directory

/usr is the largest directory because all applications are installed here, locally installed programs and other things under/usr/local.

/USR/ETC Store the configuration file.

/usr/games Store games and teaching documents.

/usr/include the header files needed to develop and compile the application.

/usr/share stores data that is structurally independent.

/usr/bin almost all user commands. Some commands are in/bin or/usr/local/bin.

/usr/sbin root file system unnecessary system administration commands, such as most service programs.

/usr/share/man,/usr/share/info,/usr/share/doc manual page, GNU information document, and various other documentation files.

/usr/lib program or subsystem of the unchanging data file, including some site-wide configuration files, the name Lib originates from the library, programming the original inventory in/usr/lib.

/usr/local locally installed software and other files here,/usr/local/bin store local add-on commands,/usr/local/include store the locally added library files.

/USR/SRC the source code of the stored program, the Linux kernel source is stored in the/usr/src/kernels.

/var directory

/var includes data to be changed when the system is generally running. Each system is specific, i.e. it is not shared with other computers over the network.

/var/catman the source file for the Cache.man page of the man page when the format is required is generally present in/usr/man/man*; some man pages may have a pre-formatted version, there are/usr/man/cat* While the other man pages need to be formatted for the first time, the formatted version exists in/var/man so that others can look at the same page without waiting for formatting. (/var/catman are often cleared, just as the temporary directory is cleared.)

/var/lib the file to be changed when the system is running normally.

Variable data for programs installed in/var/local,/usr/local (that is, programs installed by the system administrator). Note that if necessary, even locally installed programs use other/var directories, such as/var/lock.

/var/lock Lock the file. Many programs follow the convention of creating a locked file in/var/lock to support a particular device or file that they are using. Other programs Note that this lock file will not attempt to use this device or file.

/var/log log files for various programs, especially login (/var/log/wtmp log all to system log-in and logoff) and syslog (/var/log/messages store all core and System program information./var/log Files often grow in uncertainty and should be cleaned up regularly.

/var/run The information file that is valid for the system before the next boot. For example,/var/run/utmp contains information about the user who is currently logged on.

/var/spool,/var/mail,/var/news the print queue and other queue work directories. Each of the different spool has its own subdirectory under/var/spool, for example, the user's mailbox is in/var/spool/mail.

/VAR/TMP than/TMP allows for large or temporary files that need to exist for a longer period of time. (Although the system administrator may not allow/var/tmp to have very old files.)

More important Catalogs

In a Linux system, there are several directories that are particularly important to note, and the following are some of the directories that need to be noted, as well as the use of presets:

/etc: This directory is very important, as mentioned above, your boot and system data files are in this directory, so when this directory is destroyed, then your system probably almost died! In the later files, you will find that we often use the/ETC/RC.D/INIT.D subdirectory under this directory, because this INIT.D subdirectory is the place to open some Linux system services scripts (which can be thought of as a batch file). And in the/etc/rc.d/rc.local this file is the boot-up execution.

/bin,/sbin,/usr/bin,/usr/sbin: This is the placement directory of the system preset execution files, such as the userconf, netconf, Perl, GCC, C + +, and so on that the root often uses, so if you are prompted If you can't find an executable file under the characters, you can look it up in these four directories! Among them,/bin,/usr/bin is to the system user to use the instruction, and/sbin,/usr/sbin is to the system administrator to use the instruction!

/usr/local: This is the System preset directory that lets you install the packages you upgraded later. For example, when you find that an updated Web suite (such as Apache) can be installed and you don't want to upgrade your suite in RPM, you can install the Apache suite under/usr/local. Installation here has a benefit, because at present everyone's system is similar, so if your system to let others take over, it is more easy to get started! It is also easier to find the data Oh! So, if you need it, I usually add/usr/local/bin to my path.

/home: This is where the system will have an account of the population of the House directory set.

/var: This path is important! Whether it is logging in, the records of various services issues, and the usual record of service records, so when your system has a problem, you need to check the file data in this directory to see where the problem is! and mail preset placement is here too, so he is very important.

/usr/share/man,/usr/local/man: These two directories are places where you can place all kinds of kit documentation, for example, if you execute man man, the system will automatically find all the documentation in both directories.

File type:

The first flag (d or-) in the file properties can represent a directory or file, and that is the different file types, the Linux file types are mainly the following:

Regular files (regular file): is a generic type of file, in terms of the properties shown by Ls–al, the first property is [-].

In addition, according to the contents of the document, it can be divided into two types of documents:

Plain text file (ASCII): This is the most of the Unix system, almost as long as we can be used as a set of files belong to this kind;

Binary file (binary): usually executes the file in addition to the scripts (text-based batch file), is this kind of document format;

Directory: is the directory! The first attribute is [d];

Link: It's like a shortcut under Windows! The first property is [l];

Device: Some files that are related to the perimeter of the system are usually concentrated in the/dev directory! It is usually divided into two types:

Block device file: is some storage data to provide system access to the interface device, simply said the hard disk! For example, your hard drive code is/DEV/HDA1 and so on file! The first attribute is [b];

Character (character) device file: That is, some serial port interface devices, such as keyboard, mouse and so on! The first property is [C].

file System (inode) for Linux:

In the Linux system, each file not only has the content data of the file, but also includes various attributes of the file, such as: Group, user, executable, file settling time, file special attribute and so on. We divide the contents of each file into two parts, one is the attribute of the file and the other is the content of the file.

To cope with these two different things, ext2 plans the Inode and block to store the file's attributes (in the Inode) and the contents of the file (placed in the Block area) separately. When we want to format a partition to Ext2, we have to specify the size of the inode and Block, that is, when partition is formatted as a ext2 file system, he must have inode table and Block area two areas.

The Block has already been mentioned earlier, and he is the smallest unit of data storage. So what is the inode?! To put it simply, block is the area where "file content data" is recorded, and the inode is the information that records "The attributes of the file and within which block the file contents are placed". In short, the inode, in addition to recording the attributes of the file, but also must have a point (pointer) function, that is, point to the file content placed in the block, so that the operating system can correctly get the contents of the file Ah

    • The owner and group of the file (Owner/group);
    • The access mode of the file;
    • The type of the file;
    • The date the file was established (CTime), the last Read time (atime), the last Modified time (mtime);
    • The capacity of the file;
    • Defines flags (flag) for file attributes, such as SetUID ... ;
    • The point of the real content of the file (pointer);

Reproduced in: 72844025

Linux directory structure and detailed introduction

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.