Introduction to Linux file types and directories

Source: Internet
Author: User

Reference: http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/20/3033131.html

One: Linux file types and extensions

1. Types of documents

  • Normal file (regular files): The Display property is [-], for example [-rwxrwxrwx]. In addition, according to the contents of the file, it can be divided into: directory: display property is [d], for example [drwxrwxrwx].
    • Plain text file (ASCII): This is the most common type of file in a Linux system.
    • Binary (binary): binary (binary file) can be executed, which is an executable file in Linux. Where the text-type batch file does not count (scripts).
    • Data format file: A file in a specific format. Need to be read by a specific instruction.
  • Connection file: just like a shortcut under Windows System! The Display property is [l] (lowercase of L), for example [lrwxrwxrwx];
  • device and device files: Some files related to the perimeter and storage of the system are usually concentrated in the/dev directory. There are two types of data interface files (sockets): The first property is [s], which is usually used for data on the network. Often stored in the/var/run.
    • Block device file: The property is [b], which is some storage data to provide system random access to the interface device, such as: hard disk and floppy disk. Saved in/DEV/SDA.
    • Character (character) device file: The property is [C], which is the interface device of some serial port, for example: keyboard, mouse, etc. The features of these devices are "one-time read" and cannot truncate the output.
  • data transfer file (FIFO, pipe,first-in-first-out): The first property is [P], which is a special file type. Mainly solves the error problem caused by multiple programs accessing one file at the same time.

If you have any further information about this. We recommend searching for relevant information. Or view a reference source.

2.Linux file extension:

The extensions under Linux do not have any actual use (win under).

The ability to execute depends on: The file itself and the Execute permission (x in r/w/x).

However, we can know the file type by extension to use to open or execute for the software. For example:

    • *.sh: script or batch file (scripts) because the batch file is written by the shell, so the extension is. sh;
    • *z, *.tar, *.tar.gz, *.zip, *.tgz: Different compression extensions.
    • *.html, *.php: web-related documents

3.Linux file length and filename restrictions

The file name length limit for files is:

    • The maximum allowable file name of a single file or directory is 255 characters;
    • The full file name containing the full path name and directory (/) is 4,096 characters.

Try to avoid the following characters:

* > < &! [ ] | \ ' "' () {}

These symbols have special meanings under the text interface: The file name is in the decimal point "." Starts with a "hidden file".

Some symbols are used in Linux directives: symbols [-] are used in-option.

Third, the Linux directory structure

The main features of the Linux directory are:

    • The starting point of the directory is the root directory (/, root);
    • Directories can not only use the partition file system on the local side, but also use the filesystem on the network. Example: You can use the Network File System (NFS) server to mount a specific directory, and so on.
    • Each file name (including the full path) in this directory tree is unique.

Linux Open source features lead to numerous developers. The catalog is cluttered and requires a uniform standard.

FHS (http://www.pathname.com/fhs/): Is the directory specification standard under Linux. Full name:Filesystem Hierarchy Standard.

FHS: Only the main directory under the canonical root (/) should be the file to be placed.

FHS defines the two-tier specification:

1) The first layer is/under the various directories should be placed on what content of the file data, such as/etc should be placed configuration files.

2) The second tier is defined for the sub-directories of the/USR and/var directories. For example,/var/log places the system registry file.

FHS defines the directory as a form of four interactions based on the frequent use of file systems and whether users are allowed to change them:

  Shareable (shareable) Non-shareable (unshareable)
Constant (Static) /usr (software placement) /etc (config file)
  /OPT (third party collaboration software) /boot (boot and core file)
Variable (variable) /var/mail (User mail box) /var/run (program-related)
  /var/spool/news (News Group) /var/lock (program-related)
    • 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;
    • Not to be shared: The device file or socket file related to the program is not suitable for sharing with other hosts because it is only related to its own machine.
    • Constant: Some of the data is not constantly changing, along with distribution without change. For example, a function library, file description file, the system administrator manages the host service configuration file and so on;
    • Variable: frequently changing data, such as log-in files, newsgroups that are normally accepted by users, and so on.

We can see that all of these directories are attached to the "/" root directory, which is what we commonly called "tree-like directory." According to the FHS definition, the file contents that should be placed within each directory should be as follows:

Directory File contents should be placed
/bin The system has a lot of directories for executing files, but/bin is more special. Because the /bin is placed in the single maintenance mode can also be operated instructions. 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 is mainly used to put the files on the boot, including the Linux core files and boot menu and boot required configuration files and so on. Linux kernel commonly used file name: Vmlinuz, if you are using grub this boot manager, there will be/boot/grub/this directory!
/dev On a Linux system, any device or interface device is present in this directory in the form of a file. All you have to do is access one of the files under this directory to access a device that is more important than /dev/null,/dev/zero,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*, etc.
/etc Most of the system's 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 are accessible to the general user, but only root has the power to modify it. 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/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.
/home This is the system default user home directory (home directory). When you add a general user account, the default home directory will be standardized here. More importantly, the home directory has two types of code: ~: Represents the current user's home directory, and ~xiaoluo: it represents xiaoluo home directory!
/lib The system has a much more functional library, and /lib places a library of functions that will be used at boot time, as well as a function library that the instructions 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 especially important to /lib/modules/this directory, because the directory will place the core related modules (drivers)!
/media Media is the "medium" of English, as the name implies, this /media is placed under the removable device! Such devices as floppy disks, CDs, DVDs and so on are temporarily mounted here. Common file names are:/media/floppy,/media/cdrom, and so on. (Our disc image files are usually mounted in the media directory)
/mnt If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In ancient times, the use of this directory is the same as/media! Just after the/media, this directory is used for temporary loading.
/opt This is the 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). The reason for this is that if you go into single-player maintenance mode and only mount the root directory, that directory will be able to have the 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 to set up the system environment, these instructions only root can be used to "set up" system, the 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 instructions. As for some server software programs, it is generally placed in the/usr/sbin/. The system binaries generated by the natively installed software are placed in the/usr/local/sbin/. Common directives include: fdisk, fsck, Ifconfig, Init, MKFS, and so on.
/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 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 the data at/TMP should be removed when booting
/lost+found This directory is a directory that is generated using the standard EXT2/EXT3 file system format, in order to place some missing fragments into this directory when the file system has an error. This directory usually exists at the top level of the splitter slot, for example if you add a hard disk to/disk, and the system will automatically generate a directory like "/disk/lost+found"
/proc This directory itself is a "virtual file system (FileSystem)" Oh! The data he places are in memory, such as the system core, the trip information (process), the state of the peripheral device, and the 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/* and so on.
/sys This directory is very similar to/proc, but also a virtual file system, which is also the key to record the information related to the core. Including the core modules currently loaded and the core detected hardware device information, and so on. This directory also does not account for hard disk capacity
usr The second level of content by the FHS specification, in/usr This directory, contains the system's main program, graphics interface required files, additional library, the local side of the software installed by itself, as well as shared directories and files, etc., can be found in this directory. In fact, he is a bit like the "Program Files" and "WinNT" in the Windows operating system to combine the two directories! The important sub-directories under this directory are:
  • /usr/bin,/usr/sbin: directory where the general identity user and the system administrator can perform file placement;
  • /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! ;
  • /usr/lib: The library files directory of each application software;
  • /usr/local: The default directory where the native-side software installs itself. It is also available for the/OPT directory. After you have installed Linux, basically all the equipment you have, but the software can always be upgraded, for example, you want to upgrade your proxy service, the software is usually the default installation is in the/usr/local (Local is "locally" meaning), at the same time, After the installation of the resulting execution files, in order to be different from the original execution of the system, so the upgraded execution file is usually placed in the/usr/local/bin this place.
  • /usr/share: A directory for shared file placement, such as the bottom two directories:
  • /usr/share/doc: Place some system documentation, for example, if you have grub installed, then look it up under that directory and you can find the GRUB documentation! It is very convenient!
  • /usr/share/man:manpage file directory, when using man, will go to query the path! For example, when you use the man ls command, you will find the contents of/usr/share/man/man1/ls.1.gz this document!
  • /usr/src:linux system-related program code placement directory, such as/usr/src/linux as the core of the original code!
  • /USR/X11R6: Almost all of the execution files required for the X Window system within the systems are placed here!
/ var This directory is also important and is the second-level directory content of the FHS specification. His main place is for the system execution process, the normal changes in the file placement directory. For example, a cached file (cache), or a log file that is changed at any time, is placed in this directory. In addition, some of the database files that are written during the execution of the software, such as the MySQL database, are also written in this directory! Below are the important directories:
  • /var/cache: Some temporary disks in the process of the program files;
  • /var/lib: The program itself executes the process, need to use the data files placed in the directory, for example, locate this database and MySQL and RPM database system, are written in this directory.
  • /var/log: directory where the login file is placed. It's important! For example/var/log/messages is a file of all login files!
  • /var/lock: Some devices have a one-time write feature, such as a tab (tape drive), which, in order to be disturbed by other people to disrupt the operation of the action, therefore, the device lock (lock) up to determine that the device can only be used by a program!
  • /var/run: After some programs or services are started, their PID will be placed in this directory!
  • /var/spool: is where some queue data is stored. For example, when the host receives the e-mail, it will be placed in the/var/spool/mail, if the letter is temporarily not sent out, it will be placed in the/var/spool/mqueue directory, the user task Assignment (cron) is placed in the/var/spool/cron Of

Several categories of particular importance

    • /etc: This directory is where the system configuration files are placed, including the account number and password (/etc/passwd,/etc/shadow) on your system, as well as the set values (/etc/sysconfig/*) to be used when booting, as well as the configuration files of each major network service. are in this directory. This means that if the files under this directory are deleted or are dead, we will have to spend a lot of time restoring the files in this directory. Therefore, it is generally recommended that this directory be backed up!
    • /usr/local: Although the importance of this directory has now been moved to/OPT, I am still more accustomed to placing myself in this/usr/local directory with software that I have developed myself or installed on my own. If your Linux system is a multi-person condominium, it is necessary to develop a good operating habit. Then the habit of installing software should be well built up AH ~ do not install it at random! Put it in the/usr/local or under the/opt!
    • /var: This directory is an important intermediate staging data during the operation of the management system, such as/var/lib and/var/run. In addition, the final data such as Mail/var/spool/mail is also placed in this directory in addition, almost all the services of the login file (can record who, when, where to log in the machine, what to do and so on information! are placed in the/var/log directory, so this directory is also important.

Iv. relative paths and absolute paths:

Absolute path: The name of a file or directory, such as/HOME/XIAOLUO/.BASHRC, that is started by the root directory (/).

Relative path: The name of the file that is relative to the current path ( It is not the same as the path). such as./home/xiaoluo or http://www.cnblogs.com/home/xiaoluo/, and so on.

Pay particular attention to these two special directories:

    • . : Represents the current directory, or it can be used.
    • .. : Represents the previous level of the directory, or you can ... /to represent.

Introduction to Linux file types and directories

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.