One Linux command per day--linux file type and extension

Source: Internet
Author: User

The Linux file type and the name of the Linux file represent the meanings of two different concepts. We created it through generic applications such as File.txt file.tar.gz. Although these files are to be opened in different programs, they are mostly regular files (also known as normal files), measured in the Linux file type.

I. Types of files

Common to Linux file types are: Normal files, directory files, character device files and block device files, symbolic link files, and so on, now we have a brief description.

1. Common documents

We use LS-LH to see the properties of a file, we can see similar-rwxrwxrwx, it is worth noting that the first symbol is-, such a file in Linux is a normal file, these files are usually created with some related applications, such as tools, document tools, archiving tools ... or CP tools. This type of file is deleted using the RM command. In addition, according to the contents of the document, but also can be divided into:

1>. 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 use the command: Cat ~/.BASHRC to see the contents of the file. (Cat is an instruction to read the contents of a file)

2>. binary file (binary):

Linux systems only know and can execute binary files (binary.file), Linux executable files (script, text-type batch file is not counted) is the file in this format. The cat command is also a binary file.

3>. data format file:

Some programs read files in certain formats while they are in operation, and those files in a particular format can be referred to as data files. For example, when the user logs on, our Linux records the log amount data in the/var/log/wtmp file, which is a data file that can be read through the last command. However, when using cat, garbled characters are read. Because he belongs to a special format file.

2. Catalog files

When we execute in a directory, see similar drwxrwxrwx, such files are directories, directories in Linux is a more special file. Note that its first character is D, and the command to create the directory can be mkdir,

or the CP Copy command. Delete with RM or rmdir.

3. Character device or block device file

If you enter the/dev directory, list the files, you will see a lot of TTY SDA and other files

The/dev/tty property is crw-rw-rw-, and the file that starts with C indicates that this is a character device file. such as modems.

And the/dev/sda1 property is the brw-r-----, note that the first character in front is B, which indicates a block device, such as a hard disk, an optical drive, and so on.

This type of file is created with Mknode and is deleted with RM. Currently in the latest Linux distributions, we generally do not have to create our own device files, because these files are associated with the kernel.

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 (block) device file:

is some storage data to provide system random access to the interface device, for example, hard disk and floppy disk, etc. belong to this category.

You can read and write randomly in different chunks of the hard drive, which is a set of devices. You can check the/DEV/SDA yourself, and you'll find that the first property is [b].

Character (character) device file:

That is, some serial port interface devices, such as keyboards, mice, and so on. These devices feature a one-time read and cannot truncate the output. For example, you can't let the mouse jump to another screen, but east to another place. The first property is [C].

4. Data interface file (sockets):

Data interface files (or: Socket files), this type of file is usually used for data on the network to undertake. 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.

For example: When we start the MySQL server, a mysql.sock file is generated. SRWX------file format is s

5. Symbolic Link File:

When we look at the file properties, we see a similar lrwxrwxrwx. When a local character is L, this type of file is a linked file. is the new file name by ln-s the source file name. Above is an example that indicates that Setup.log is

Install.log Soft-Link file. How do you understand that? We can understand the shortcuts in the Windows operating system.

With regard to links and shortcuts, if a file under a running program is used instead of the source file, the program runs without automatically jumping through the link, but will report a missing XXX hint. (Windows environment)

6. 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].

Ii.. linux file extension

1. Extension type

Basically, the Linux file is not the so-called extension, a Linux file can be executed, and his first column is a property related, and the file name has no relationship at all. This concept is not the same as the case with Windows. Under Windows, the file name extensions that can be executed are usually. com. exe. bat and so on, and under Linux, as long as you have x in your permission, for example [-rwx-r----] That means the file can be executed.

However, can be executed and can be executed is not the same, 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 successfully? Of course not, because his content has no data that can be executed at all. So, this x represents the ability of the file to execute, but if it succeeds, it depends on the content of the file.

Even so, we still want to know what the file is because of the 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 programmed. sh

*z, *.tar, *.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 that represent HTML syntax and PHP syntax for Web pages. html files can be opened directly using a Web browser, and as for. php files, you can browse through the server side of the client browser to get the operation The Web page results.

Basically, a file name on a Linux system really just lets you know what the file might be used for, and the actual execution will still require permission specifications. For example, although there is a file for an executable file, such as the common/bin/ls directive that displays the file attributes, if the permissions of this file are modified to be unenforceable, then LS becomes unenforceable.

The above problems occur most often in the process of file transfer. For example, you download an executable file on the network, but it just can't be done on your Linux system. Then it is possible that the properties of the file have been changed. Do not suspect that the properties and permissions of a file are actually changed from the network to your Linux system.

2.Linux file name length limit:

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

Maximum allowable file name of a single file or directory is 255 characters

Full path name and table of contents (/) with full file name of 4,096 characters

is quite a long file name so that we can see the purpose of the file at a glance.

Limitations of characters for 3.Linux filenames:

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.

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

These symbols are of special significance under the text interface. In addition, the beginning of the file name is a decimal points. Represents this file as a hidden file. At the same time, as the command is released, you will often use options such as-opition, so you should also avoid naming the file name at the beginning of-or +.

  

One Linux command per day--linux file type and extension

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.