Linux file type and directory configuration

Source: Internet
Author: User

Linux file types and extensions

In a Linux system, any hardware device or other device is in the form of a file, and even the interface of data communication is responsible for the special files, so there are many types of Linux files, out of our common-or D to represent the general file and directory files, What kinds of documents are there?

1. Types of documents

When we use the ls-l command, we can observe the first column of the 10 characters, the first character is the type of the file. What kinds of file types are there in addition to the common general file (-) and catalog file (d)?

  • ordinary files (regular file): is the type of file that we are accessing, in terms of the attributes shown by Ls-al, the first character is [-], for example [-rwxrwxrwx]. In addition, according to the contents of the document, but also can be divided into:
    • Plain text file (ASCII): This is the most common type of file in a Linux system, known as a plain text file because the content is data that we humans can read directly, such as numbers, letters, and so on. Almost as long as we can use it as a set of files belongs to this file type. For example, you can release "Cat ~/.BASHRC" to see the contents of the file. (Cat is an instruction to read the contents of a file)
    • Binary (binary): Our system actually knows only and can execute binary files (binary file) in Linux executable files (scripts, text-type batch file not counted) is this format for example, we often use the cat The command is a binary file.
    • Data format files: Some programs read certain files in a particular format during operation, and those files in a particular format can be referred to as data files. For example, when the user logs on, our Linux logs the logged-in data in the/var/log/wtmp file, which is a data file that can be read through the last command! However, when using cat, it will read garbled characters because it belongs to a special format file.
  • directory: The first property of a directory is [d], for example [drwxrwxrwx].
  • Connection file: just like a shortcut under Windows System! The first property is [l] (lowercase in English 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! It is usually divided into two types:
    • Block device file: is some storage data to provide system random access to the interface device, for example, hard disk and floppy disk is! You can read and write randomly in different chunks of the hard drive, which is a group device! You can check the/DEV/SDA yourself, and you'll find the first property is [b]!
    • Character (character) device files: This is the interface device for some serial ports, such as keyboards, mice, and so on! The features of these devices are "one-time read" and cannot truncate the output. For example, you can't let the mouse "jump" to another screen, but instead "swipe" to another place! The first property is [C].
  • Data Interface file (Sockets): since it is called a data interface file, it is assumed that this type of file is usually used for data on the network. We can start a program to listen to the client's requirements, and the client can communicate the data through the socket. The first property is [s], which is most commonly seen in the/var/run directory.
  • data transfer file (FIFO, pipe): FIFO is also a special type of file, and his main purpose is to solve the error caused by multiple programs accessing a file simultaneously. FIFO is the abbreviation for first-in-first-out. The first property is [P].

In addition to the device files are very important in our system files, it is best not to arbitrarily modify outside (usually only the root user can modify!) ), another interesting file is the link file. If you often catch the app on the desktop, you should know that there are so-called " shortcuts" underneath Windows. Similarly, you can simply consider a link file under Linux as a shortcut to a document or directory. As for the socket and FIFO file is difficult to understand, because these two things compared with the program (process), this wait until later study! In addition, you can check the instructions on the system through the man FIFO and the mans socket!

2.Linux file extension:

Basically, the Linux file is not called "extension", a Linux file can be executed, and his first column of the 10 attributes, and the file name is not at all related. This concept is not the same as the Windows situation! Under Windows, the file name extensions that can be executed are usually. exe. bat and so on, and under Linux, as long as you have x in your permission, for example [-rwx-r-xr-x] That means the file can be executed!

However, can be executed and can be executed is not the same as the success of ~ For example, in the root directory of the Install.log is a plain text file, if through the modification of the permission to become-rwxrwxrwx, this file can really execute success? Of course not ~ because his content simply does not have the data that can be executed. So, this x represents the ability of the file to execute, but if it succeeds, it will have to look at the contents of the file.

Nevertheless, we still want to be able to understand what the file is by extension, so we will usually indicate what kind of file it is with the appropriate extension. There are several common extensions at the bottom:

    • *.sh: script or batch file (scripts), because the batch file is written using the shell, so the extension is compiled. Sh;
    • *z, *.tar, *.tar.gz, *.zip, *.tgz: Packaged compressed files. This is because the compression software is gunzip, tar and so on, due to different compression software, and take its associated extension!
    • *.html, *.php: Web-related files, respectively, representing HTML syntax and PHP syntax of the Web page file!. html files can be opened directly using a Web browser, as for. php files, you can browse through the server side of the client browser to get the operation Page results!

Basically, the name of the file on the Linux system really just lets you know what the file might be used for, and the actual execution will still require permission specification! For example, although there is a file for the executable file, such as the common/bin/ls this shows the file attributes of the instructions, however, if the permissions of the file is modified to be unable to execute, then the LS becomes unable to execute!

3.Linux file length and filename restrictions

Under Linux, when using a preset ext2/ext3 file system, the file name length is limited to:

    • 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.

Because of the Linux in the text interface some of the instructions to operate the relationship, in general, you set the name of Linux under the file, it is best to avoid some special characters better! For example under these:

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

Because these symbols in the text interface, there is a special meaning! Additionally, the file name begins with the decimal point "." , this file is "hidden file"! At the same time, because of the command release, often use the-option and other options, so it is best to avoid the file name at the beginning of-or + to name!

Linux file type and directory configuration

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.