The file type and file extension in Linux system

Source: Internet
Author: User
Tags root directory

The Linux file type and the file name of the Linux file represent two different concepts. We create things like file.txt and file.tar.gz through a generic application, which, although used in a different program, is mostly a regular file (also known as a normal file) when measured in a Linux file type.

 I. File type

Linux file types are common: Ordinary files, directory files, character device files and block device files, symbolic link files, and so on, we now make a brief explanation.

1. Ordinary Documents

We use LS-LH to view the properties of a file, we can see similar-rwxrwxrwx, it is noteworthy that the first symbol is-, such a file in Linux is a normal file. These files are typically created with related applications, such as image tools, document tools, archiving tools ... or CP tools. This type of file is deleted by using the RM command. In addition, according to the contents of the document, and roughly can be divided into:

1>. Plain text file (ASCII):

This is one of the most file types in the Linux system, known as plain text because it is the data that we humans can read directly, such as numbers, letters, and so on. Almost as long as we can use it as a setup file all belong to this type of file. For example, you can use the command: Cat ~/.BASHRC to see the contents of the file. (Cat is the instruction that reads the contents of a file).

2>. Binary file (binary):

Linux systems are actually only known and can execute binaries (binary file). Executable files in Linux (scripts, text-batch files are not counted) are files of this format. The command cat just used is a binary file.

3>. Data Format files:

Some programs will read files in certain formats while they are operating, and those files in a particular format can be called data files. For example, when a user logs on, our Linux records the logged in to the/var/log/wtmp file, which is a data file that he can read through the last command. But when using cat, will read garbled ~ because he belongs to a special form of file?

2. catalog file

When we execute in a directory, see a similar drwxr-xr-x, such a file is a directory, the directory in Linux is a relatively special file. Notice that its first character is d. You can create a directory by using the mkdir command, or the CP command, where the CP can copy a directory to another directory. Delete with RM or RmDir command.

3. Character device or block device file

If you enter the/dev directory, you will see a list of files similar to the following:

The code is as follows:

[Root@localhost ~]# Ls-al/dev/tty

Crw-rw-rw-1 Root TTY 5, 0 11-03 15:11/dev/tty

[Root@localhost ~]# ls-la/dev/sda1

Brw-r-----1 Root Disk 8, 1 11-03 07:11/dev/sda1

We see that the/dev/tty property is crw-rw-rw-, and note that the first character is C, which represents the character device file. such as cats and other serial devices. We see that/DEV/SDA1 's properties are brw-r-----, and note that the first character in front is B, which means a piece of equipment, such as a hard disk, optical drive, and so on.

This kind of file, is created with Mknode, with RM to delete. Currently, in the latest Linux distributions, we typically do not have to create the device files ourselves. Because these files are associated with the kernel.

Some files related to the system's perimeter and storage are usually concentrated in the/dev directory! There are usually two types:

Chunk (block) device file:

is a number of storage data to provide system random access to the interface equipment, for example, hard disk and floppy disk, etc. is it! You can randomly read and write in different blocks of your hard disk, and this device is a group of devices! You can check it out on your own/DEV/SDA. The first attribute is [b]!

Character (character) device file:

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

4. Data interface file (sockets):

Data interface file (or: A set of interface files), this type of file is usually used on the network to undertake the data. We can start a program to listen to the requirements of the client, and the client can through the socket to communicate the data. The first property is [s], which is most often seen in the/var/run directory.

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

The code is as follows:

[Root@localhost ~]# Ls-lh/var/lib/mysql/mysql.sock

srwxrwxrwx 1 mysql mysql 0 04-19 11:12/var/lib/mysql/mysql.sock

Note that the first character of the property of this file is S.

5. Symbolic Link File:

When we look at the file properties, we see a similar lrwxrwxrwx, noting that the first character is L, which is a linked file. is the new file name by ln-s the source file name. The above is an example of Setup.log is a install.log soft link file. How do you understand that? This is a bit like the shortcuts in Windows operating systems.

Example of how to create a symbolic link file:

The code is as follows:

[Root@localhost test]# Ls-lh Log2012.log

-rw-r--r--1 root root 296K 11-13 06:03 log2012.log

[Root@localhost test]# ln-s Log2012.log linklog.log

[Root@localhost test]# LS-LH *.log

lrwxrwxrwx 1 root 11-22 06:58 linklog.log-> log2012.log

-rw-r--r--1 root root 296K 11-13 06:03 log2012.log

6. Data transmission Document (FIFO,PIPE):

FIFO is also a special type of file, and his main purpose is to solve the problem of error caused by multiple programs accessing a file at the same time. FIFO is the abbreviation of first-in-first-out. The first property is [P].

Two. linux file name extension

1. Extended Name Type

Basically, Linux files are not called extensions, a Linux file can be executed, and his first column of 10 attributes, and the file name does not have any relationship. This is not the same idea as 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 permissions, for example [-rwx-r-xr-x] That means the file can be executed.

However, it can be performed differently than can be executed. For example, the Install.log in the root directory is a plain text file, and if you become a-rwxrwxrwx by modifying permissions, does it really work? 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 whether it succeeds, of course, depends on the contents of the file.

Nonetheless, we still want to know what the file is by extension, so we usually indicate what kind of file it is in the appropriate extension. There are several common extensions below:

*.sh: script or batch file (scripts), because the batch file is written using a shell, 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, because of different compression software, and take its relevant extension!

*.html, *.php: Web-related files, representing HTML syntax and PHP syntax for the Web page file. html files can be opened directly using a Web browser, and for. php files, you can browse through the server side of the client-side browser to get the operation Web results.

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

This kind of problem most often occurs in the process of file transfer. For example, you download an executable file on the Web, but it just can't be done on your Linux system! Oh! Then it is possible that the attributes of the file have been changed. Do not doubt that the attributes and permissions of the file will indeed be changed from the network to your Linux system.

2. Linux filename length limit:

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

The maximum allowable file name for a single file or directory is 255 characters

Full filename containing full path name and directory (/) is 4,096 characters

It's a pretty long file name! We want Linux's filename to be able to see what the file is doing, so it's usually very long.

3. Restrictions on the characters of the Linux filename:

Because Linux in the text interface with some of the command operation relationship, generally speaking, you set up Linux under the file name, it is best to avoid some special characters better! For example:

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

Because these symbols have a special meaning under the interface of the text. In addition, the beginning of the filename is the decimal point "." On behalf of this file as a hidden file! Also, because the commands are often used to-option options such as, so you'd better avoid naming the file name at the beginning of-or +.

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.