linux: 7 file types

environment:

  • centos7.6
  • ubuntu

Reference: "7 File Types of Linux System"

1. Normal file (-)

It is a normal file, such as: a text, movie, music and so on.
After using ls -l the command , "-"the file with the first character in the first column is an ordinary file ( -Fno special mark after use), such as:
insert image description here

2. Directory (d)

That's what we think of as a directory. Just like folders on windows.
Use ls -lthe command to view, the first character is "d"(directory), if it is appended -F, it will be appended at the end of the directory name /, as follows:
insert image description here

3. Linking files (l)

A link file generally refers to a soft link (or symbolic link) of a file, just like a window shortcut.
Use ls -lthe command to view, the first symbol is "l"and the file name shows the specific location pointed to, -Fafter the addition, the name shows basically no change, as follows:
insert image description here
insert image description here

Note: Link files have hard links and soft links, we generally use soft links. The hard link of the file is the same as the file itself, internally pointing to the same inode, and ls -lthe first symbol of the result is still -.

4. Block device (b)

Block device files generally refer to storage devices such as hard disks and floppy disks. Use ls -lthe command to view, the first character of the block device file is "b"(block), -Fafter appending, there is no change after the name, as follows:
insert image description here

5. Character device (c)

Character device files are accessed in the form of byte streams, and this feature is implemented by character device drivers, which usually use system calls such as open, close, read, and write. Character terminals, serial ports, and keyboards are character devices. In addition, since the character device file is accessed in the form of a file stream, it can be read sequentially, but usually does not support random access. Use the ls -l command to view, the first character of the character device file is "c" (char).

We can observe /dev/console:
insert image description here

We can observe its operation, for example, we /dev/consoleinput :
insert image description here
Of course, we can also get output from character devices. . .

6. Pipeline file (p)

The pipe file is mainly used for inter-process communication, use the ls -l command to view, the first character is "p" (pipe), if you use it, -Fappend it at the end |. A pipeline file can be created using the mkfifo command:
insert image description here
we can manipulate it with two threads:

insert image description here

7. Socket file

Socket files are mainly used for communication, especially on the network. Use the ls -l command to view, the first character is "s" (socket), if you use -Fthe last append =.
as follows:
insert image description here

Guess you like

Origin blog.csdn.net/u010476739/article/details/127212084