How to find the file location in Linux: 1. Use the find command to find files in the specified directory; 2. Use the locate command to find documents that meet the conditions. Enter locate your_file_name to find the specified file. ; 3. Use the which command to search for qualified files in the directory set by the environment variable $PATH; 4. Use the whereis command to search for qualified files in a specific directory.
#The operating system of this tutorial: linux5.18.14 system, Dell G3 computer.
How to find the file location in Linux
1. Use the find command
The Linux find command is used to find the file location in the specified directory. Find files. Any string preceding the parameter will be treated as the name of the directory to be searched. If you use this command without setting any parameters, the find command will search for subdirectories or files in the current directory. And all found subdirectories and files will be displayed.
Syntax: find path -option [ -print ] [ -exec -ok command ] {} \;
2. Use the locate command
The Linux locate command is used to find documents that meet the conditions. It will search for documents or directories that meet the template style conditions in the database that saves document and directory names.
Generally, we only need to enter locate your_file_name to find the specified file.
Syntax: locate [-d ][--help][--version][Template style...]
3. Use which command
Linux which command is used to find files.
which command will search for files that meet the conditions in the directory set by the environment variable $PATH.
Syntax: which [file...]
4. Use the whereis command
The Linux whereis command is used to find files.
This command will search for files that meet the conditions in a specific directory. These files should be raw code, binary files, or help files.
This command can only be used to find binary files, source code files and man pages. Generally, you need to use the locate command to locate files.
Syntax: whereis [-bfmsu][-B
The above is the detailed content of What are the methods to find file location in Linux?. For more information, please follow other related articles on the PHP Chinese website!