Home  >  Article  >  Operation and Maintenance  >  How to find file location in linux

How to find file location in linux

藏色散人
藏色散人Original
2023-01-04 11:31:3016549browse

How to find the file location in Linux: 1. Use the "whereis bash" command to view the location of the executable file or source code file in the file system; 2. Use the find command to search for files in the directory structure and find File location; 3. Use the which command to search for the location of a system command in the path specified by the PATH variable.

How to find file location in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

How to find the file location in Linux?

Linux view file location

1.whereis

thewhereis command is to locate the executable file , the location of source code files and help files in the file system.

The attributes of these files should belong to original code, binary files, or help files.

whereis The program also has the ability to search source code, specify alternative search paths, and search for unusual items.

If parameters are omitted, all information will be returned.

test@localhost:~$ whereis bash
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz

Note: The above output information from left to right is the queried program name, bash path, and bash man manual page path.

2. find

The find command under Linux searches for files in the directory structure and performs the specified operation.

The find command under Linux provides quite a few search conditions and is very powerful. Because find has powerful functions, it also has many options.

sudo find . -name "*.log"

Description: Search for files ending with .log in the current directory. "." represents the current directory

sudo find / -name "*.log"

Description: Search for files ending with .log in the root directory. "/" represents the current directory

3. The function of which

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

In other words, using the which command, you can see whether a certain system command exists and which location the command is executed.

Enter export on the command line to view the PATH variable

export

How to find file location in linux

which java

Description: View the address of the java executable file

Note:

which View the location of the executable file.
whereis View the location of the file.
find Actually searches the hard disk to query the file name.

Recommended learning: "Linux Video Tutorial"

The above is the detailed content of How to find file location in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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