Home > Operation and Maintenance > Linux Operation and Maintenance > How to determine whether it is a file or a directory in Linux

How to determine whether it is a file or a directory in Linux

WBOY
Release: 2022-03-02 12:00:46
Original
13429 people have browsed it

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.

How to determine whether it is a file or a directory in Linux

#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

How to determine whether it is a file or a directory in Linux

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"

How to determine whether it is a file or a directory in Linux

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template