File Types and File Extensions in Linux Systems

file types in linux

In a linux system, it can be said that everything is a file. File types include ordinary files, directories, character device files, block device files, symbolic link files, and more.

type c 
File is of type c:

  1. b: block (buffered)special block device file
  2. c: character(unbuffered)special character device file
  3. d: directory directory
  4. f : regular file ordinary file
  5. l : symbolic link symbolic link file
  6. s: socket socket file

1. b:block

The first attribute of a block device file is "b".


[root@ianLinux ~]# find /dev -type b|xargs ls -l
brw-rw---- 1 root disk   7,  0 92 2016 /dev/loop0
...
  • 1
  • 2
  • 3
  • 4

A block device is an interface device that stores data for system and program access, such as hard disks, optical drives, etc.

2. c:character

A character device is an interface device of a serial port, such as a serial port device such as a cat. 
The first attribute of character device files is "c".

[root@ianLinux ~]# find /dev -type c|xargs ls -l
crw-rw---- 1 root video    10, 175 9月   2 10:02 /dev/agpgart
  • 1
  • 2

5. f :regular file

The first attribute of ordinary files is "-". Ordinary files are divided into 3 types.

  • Plain text file (ascll): The text content can be read directly into data, such as letters, numbers, etc. The file can be read with the cat command.

  • Binary: Executable files (commands) in linux belong to this format. For example, the cat executable file is a binary file.

  • Data format file (data): Some programs will read files in certain specific formats during the running process, and the files in specific formats can be called data files. For example, when a user logs in, Linux will record the login data in the file /var/log/wtmp, which is a data file. Read it out with the last command. The cat command will read garbled characters. Because he belongs to a special format file.

Use the command to determine the file type of a common file:

file +file 
write picture description here

are normal files. 
write picture description here

6. s: socket socket file

When we start the MySQL service, a mysql.sock file is generated. The first attribute of this file is "s".

file extension in linux

In Windows, file types are distinguished by their extensions. File extensions and file types in linux have nothing to do with each other. However, in order to be easy to distinguish and compatible with the habit of users using windows, we will still use the extension to indicate the file type. An example is as follows:

  • The source code .tar, .tar.gz, .tgz, .zip, and .tar.bz represent compressed files, and the creation commands are generally tar, gzip, zip, etc.
  • .sh represents a shell script file, a program developed through the shell language.
  • .pl represents a perl language file, a program developed through the perl language.
  • .py represents a python language file, a program developed through the python language.
  • .html, .htm, .php, .jsp, .do are files representing the language of the web page.
  • .conf represents the configuration file for system services.

  • .rpm represents the rpm installation package file.

Reprinted to https://blog.csdn.net/codetz/article/details/52413029

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325806077&siteId=291194637