Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the query command of Linux system

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you what the query command of the Linux system is, which is concise and easy to understand, which can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Linux system query file command can use which, whereis, locate, find and other methods.

1. The whichwhich command searches the location of a system command in the path specified by the PATH variable and returns the first search result. That is, using the which command, you can see if the system command exists and where the command is being executed.

Command format: which executable file name

The which instruction searches for the location of a system command in the path specified by the PATH variable and returns the first search result.

2. The whereiswhereis command is used to search program names, and only binary files (parameter-b), man description files (parameter-m), and source code files (parameter-s) are searched.

Compared with find, whereis lookup is very fast, because the Linux system will record all the files in the system in a database file, when using whereis and locate, it will look for data from the database, rather than traversing the hard disk as find does, so it will be very efficient.

But the database file is not updated in real time, so when using whereis and locate to find the file, sometimes you will find the deleted data, or the newly created file cannot be found, because the database file has not been updated.

Command format:

Whereis [- bmsu] [BMS directory name-f] file name

Command function: the whereis command is to locate executable files, source code files, and the location of help files in the file system. The properties of these files should belong to the original code, binaries, or help files. Whereis programs also have the ability to search source code, specify alternate search paths, and search for unusual items.

Parameters:

-b: locate the executable file

-m: locate the help file

-s: locate the source code file

-u: search for files under the default path other than executable files, source code files, and help files.

-B: define the path to search for executable files.

-M: specifies the path to search for help files.

-S: specifies the path to search for source code files.

# # 3 、 locate

Locate allows users to quickly search for specified files in the file system. The method is to first create a database that includes all the file names and paths in the system, and then when looking for it, you only need to query the database instead of going deep into the system documents.

Command format: locate file name

Parameters:

-u: create the database from the root directory.

-U: create the database from the specified location

-e: exclude some paths from the scope of the search.

-n: specifies the maximum number of files found to be displayed

The above content is what the Linux system query command is, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report