Home  >  Article  >  System Tutorial  >  Easily master Linux query commands

Easily master Linux query commands

WBOY
WBOYforward
2024-02-11 16:00:21534browse

As a Linux user, have you ever encountered the dilemma of not knowing how to query system information? Or don't know what command to use when looking for a specific file? If so, then don’t worry because today we will introduce some commonly used Linux query commands that will allow you to get the required information from the system easily.

1、which

which command searches for the location of a system command in the path specified by the PATH variable and returns the first search result. That is to say, by using the which command, you can see whether the system command exists and where the command is executed.

Command format: which executable file name

which command will search for the location of a system command in the path specified by the PATH variable and return the first search result.

2、whereis

The

whereis command is used to search for program names, and only searches binary files (parameter -b), man description files (parameter -m), and source code files (parameter -s).

Compared with find, whereis search speed is very fast, because the Linux system will record all files in the system in a database file. When using whereis and locate, the data will be searched from the database instead of like By traversing the hard disk to search like find, the efficiency will naturally be very high.

But the database file is not updated in real time, so when using whereis and locate to search for files, sometimes deleted data will be found, 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

Easily master Linux query commands

Command function: The whereis command locates the location of executable files, source code files, and help files in the file system. The attributes of these files should be original code, binary files, or help files. The whereis program also has the ability to search source code, specify alternative search paths, and search for unusual items.

  • parameter:

  • -b: Locate executable file

  • -m: Locate help file

  • -s: Locate source code files

  • -u: Search for files other than executable files, source code files, and help files in the default path.

  • -B: Positive search path for executable files.

  • -M: Specify the path to search for help files.

  • -S: Specify the path to search source code files.

3、locate

locate allows users to quickly search whether there are specified files in the file system. The method is to first create a database that includes the names and paths of all files in the system. Then when searching, you only need to query this database without having to search deeply in the system files.

Command format: locate file name

  • parameter:

  • -u: Create the database starting from the root directory.

  • -U: Create a database starting from the specified location

  • -e: Exclude certain paths from the search range.

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

4、find

find is a very important query command.

As the Linux operating system is used in more and more fields, it is increasingly important to master Linux query commands. This article introduces some commonly used Linux query commands and their functions. I believe these commands will be of great help to you in your daily work. In future use, I hope you can better use these commands and improve the efficiency of Linux systems.

The above is the detailed content of Easily master Linux query commands. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete