How to search for files in Linux

Using the Linux system will inevitably forget the location of the file, you can use the following command to search for the file in the system. The command to search for files is "find"; "locate"; "whereis"; "which"; "type"

Baidu experience: jingyan.baidu.com

method/step

 
  1. 1

    The most powerful search command under linux is "find". Its format is "find <specified directory> <specified condition> <specified action>"; for example, use the find command to search the location of all interfaces files in the root directory, and the command format is "find / -name 'interfaces'"

  2. 2

    Use locate to search files in linux system, it is faster than find command. Because it queries the database (/var/lib/locatedb), the database contains all local file information. Use the locate command to search for the interfaces file in the root directory as "locate interfaces"

  3. 3

    Use the "whereis" command to search for all executable files or binary files in a linux system. The command to search for grep binaries using the whereis command is "whereis grep".

  4. 4

    Use the which command to see if the system command exists and return the location of the system command. Use the which command to check whether the grep command exists and the existing directory. The command is "which grep".

  5. 5

    Use the type command to check whether a command in the system is a built-in command of the system. Use the type command to check whether the cd command is a built-in command of the system; check whether the grep command is a built-in command of the system.

    How to search for files in Linux

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326433558&siteId=291194637