Linux File Types and file extensions

Source: Internet
Author: User
Article Title: Linux file type and file extension. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

1. Linux file extension;

When talking about files, you can think about Windows files, such as file.txt?file.doc=file.sys=file=, file.exe, and so on. The file type can be determined based on the file suffix. But in Linux, whether a file can be executed is not closely related to the suffix name, mainly depending on the file attributes. However, it is necessary to solve the Linux File suffix, especially when we create some files by ourselves. It is best to add the suffix, so that we can only facilitate our application.

The current Linux desktop environment is as intelligent as Windows, and the file type is associated with the corresponding program. When we open a file, the system automatically determines which application to open. From this perspective, there is no big difference between a Linux desktop and a Windows desktop.

In Linux, a file with an extension can only represent the Association of programs, but cannot indicate that the file can be executed. In this respect, the extension of Linux does not have much significance.

File.tar.gz file. tgz file.tar.bz2 file.rar file.gz file.zip... all of you are familiar with archive files. Decompress or extract the files using corresponding tools;

File. php is a file that can be opened in a browser;

Files. so are library files;

File.doc file. obt this is a file that can be opened by OpenOffice;

......

The file created with some tools has different suffixes. It depends on what tools we use, such as Gimp, gedit, OpenOffice, and other tools. The file suffix is different.

2. Linux File Type;

Linux File Types and Linux File names represent two different concepts. Similar to file.txt1_file.tar.gz created by a general application, although these files must be opened in different programs, most of them are normal files (also known as common files) that are measured in Linux file types ).

Common types of Linux Files include common files, directories, character device files, block device files, and symbolic link files. Now let's give a brief description;

2.1 common files;

[Root @ localhost ~] # Ls-lh install. log

-Rw-r -- 1 root 53 K 03-16 08:54 install. log

We use ls-lh to view the attributes of a file. We can see that there is a file like-rw-r --. It is worth noting that the first symbol is -, such a file is a common file in Linux. These files are generally created using related applications, such as tools, document tools, archiving tools... or cp tools. To delete such files, run the rm command;

2.2 directory;

[Root @ localhost ~] # Ls-lh

Total 14 M

-Rw-r -- 1 root 2 03-27 02: 00 fonts. scale

-Rw-r -- 1 root 53 K 03-16 08:54 install. log

-Rw-r -- 1 root 14 M 03-16 kernel-2.6.15-1.2025_FC5.i686.rpm

Drwxr-xr-x 2 1000 users 4.0 K 04-04 mkuml-2004.07.17

Drwxr-xr-x 2 root 4.0 K 04-19 10:53 mydir

Drwxr-xr-x 2 root 4.0 K 03-17 04-25 Public

When we run the command in a directory, we can see a file like drwxr-xr-x, which is a directory. The directory is a special file in Linux. Note that its first character is d. Run mkdir or cp to create a directory. cp can copy one directory to another. Delete the file by using the rm or rmdir command.

2.3 characters of device or block device files;

If you enter the/dev directory and list the files, you will see something similar to the following;

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

Crw-rw-1 root tty 5, 0 04-19 08:29/dev/tty

[Root @ localhost ~] # Ls-la/dev/hda1

Brw-r ----- 1 root disk 3, 1 2006-04-19/dev/hda1

We can see that the attribute of/dev/tty is crw-rw-. Note that the first character is c, which indicates the character device file. Serial devices such as cats

We can see that the attribute of/dev/hda1 is brw-r -----. Note that the first character is B, which indicates a device, such as a hard disk or a optical drive;

Files of this type are created using mknode and deleted using rm. Currently, in the latest Linux release, we generally do not need to create device files on our own. Because these files are associated with the kernel.

2.4 sets of interface files;

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

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

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

Note that the first character of the attribute of this file is s. Let's take a look.

2.5 symbolic link file;

[Root @ localhost ~] # Ls-lh setup. log

Lrwxrwxrwx 1 root 11 04-19 :18 setup. log-> install. log

When viewing the file attributes, we will see lrwxrwxrwx. Note that the first character is l, and this type of file is a link file. Is a new file name through the ln-s source file name. The preceding example shows that setup. log is a soft link file of install. log. How can this problem be solved? This is similar to shortcuts in Windows.

Example of creating a symbolic link file;

[Root @ localhost ~] # Ls-lh kernel-2.6.15-1.2025_FC5.i686.rpm.

-Rw-r -- 1 root 14 M 03-16 kernel-2.6.15-1.2025_FC5.i686.rpm

[Root @ localhost ~] # Ln-s kernel-2.6.15-1.2025_FC5.i686.rpm kernel. rpm

[Root @ localhost ~] # Ls-lh kernel *

-Rw-r -- 1 root 14 M 03-16 kernel-2.6.15-1.2025_FC5.i686.rpm

Lrwxrwxrwx 1 root 33 04-19 kernel. rpm-> kernel-2.6.15-1.2025_FC5.i686.rpm

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.