Home >Operation and Maintenance >Linux Operation and Maintenance >Linux determines whether it is a file
linux determines whether it is a file
The suffix name of the file under Linux is only to distinguish the file type, and windows They are different. For example, the text type can be named text.exe under Linux, but under Windows it will be executed as a program and an error will be reported.
So how to determine whether something is a file in Linux? In fact, on Linux, everything is a file. The key is to distinguish what type of files they are.
ls -l command
The properties of the displayed file are usually displayed in the following form:
drwxr-xr-x
File attributes | File type |
---|---|
- | Regular file, that is, file |
d | Directory file |
b | block device is a block device file, such as a hard disk; supports random access in blocks |
c | Character device is the character device file. For example, the keyboard supports linear access in units of character |
l | symbolic link is a symbolic link file, also known as a soft link file |
p | pipe is a named pipe file |
s | socket is a socket file, used to communicate between two processes |
Regular files
For regular files Generally speaking, it can be divided into binary files, xml files, db files, etc. If you want to check the type of a regular file, you can use the file command
Device class file
Normally, in The fifth column after using ls -l will display the size of the current file, but there will be two numbers in the device class file, separated by commas. This does not indicate the size.
- The first number: the major device number, used to distinguish the device type. Different devices have different major device numbers, but the same device has the same device number. It is used to determine the driver to load the device
- The second number : Minor device number, used to distinguish different devices of the same type of device, such as hard disk 1, hard disk 2, etc.
Recommendation: Getting started with linux system
The above is the detailed content of Linux determines whether it is a file. For more information, please follow other related articles on the PHP Chinese website!