In Linux, you can use the "ls -l" command to determine whether it is a file or a directory. The ls command is used to display the contents of the specified working directory. Set the parameter "-l" to display the file shape, permissions and Owner and other content, the first character is "d" when displaying directories, and "-" when displaying files.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How does Linux determine whether it is a file or a directory
First enter the ls -l command to view the file and directory details
The first character in Linux indicates whether the file is a directory, file, link file, etc.
When it is [ d ], it is a directory
When it is [ - ], it is a file;
If it is [ l ], it is a link file;
If it is [ b ], it represents the storable interface device (random access device) in the installation file;
If it is [ c ], it represents the serial port in the installation file Devices such as keyboard, mouse (disposable reading device).
The following characters are grouped into groups of three, and are all combinations of the three parameters of "rwx"
You can see the file The first character in the attribute is d, which is a directory, and the first character is -, which is an ordinary file.
There is another way to directly determine the color through the command line. In most command line software, ordinary files are generally white, and directories and link files are in color.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of How to determine whether it is a file or a directory in Linux. For more information, please follow other related articles on the PHP Chinese website!