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 ( -F
no special mark after use), such as:
2. Directory (d)
That's what we think of as a directory. Just like folders on windows.
Use ls -l
the 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:
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 -l
the command to view, the first symbol is "l"
and the file name shows the specific location pointed to, -F
after the addition, the name shows basically no change, as follows:
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 -l
the 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 -l
the command to view, the first character of the block device file is "b"
(block), -F
after appending, there is no change after the name, as follows:
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
:
We can observe its operation, for example, we /dev/console
input :
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, -F
append it at the end |
. A pipeline file can be created using the mkfifo command:
we can manipulate it with two threads:
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 -F
the last append =
.
as follows: