How to Find File in Linux
How to Find File in Linux
com/kb/find-file-linux
Linux offers multiple command-line and graphical user interface (GUI) methods for file searching. While graphical
applications offer an intuitive and organized user interface, command-line tools enable precise, criteria-based
searching.
This article will show you how to find a file in Linux using the CLI and the GUI.
For example, type the following command to find a file named image1.png located in the home directory (or one of its
subdirectories):
Use the asterisk (*) symbol as a wildcard character to search for parts of filenames. For example, the command below
looks for all the PNG files in the /home/marko/examples directory:
The output shows a list of files that match the selected criteria.
For example, type the command below to look for all the files in /home/marko/test that contain the string test file:
find /home/marko/test -type f -exec grep "test file" '{}' \; -print Copy
For each file that matches the criteria, the output shows the line where the string appears, followed by the file path.
For instance, search the examples directory for the files with image in the filename:
locate Command
The locate command offers a quicker way to find files than the find command. While find looks through file paths in
real time, locate uses a list saved in a database, making it faster but potentially less up-to-date.
Note: To ensure locate works with a fully updated database, execute sudo updatedb before a
search.
By default, locate finds all files whose names contain the string as part of the filename. For example, the command
below searches for the string image in the ~/examples directory:
Catfish
Catfish is a lightweight search tool that can use locate and find in the backend and offers various filtering options. To
search for a file in Catfish:
1. Find and open the application.
2. Type the search term in the search box at the top of the window.
3. Press Enter or select the magnifying glass icon on the right side of the search box.
A list of matches appears in the main window pane.
Conclusion
The article presented the commonly used methods to search for a file in Linux. It included the command-line tools, such
as the find and the locate commands, and introduced two GUI alternatives.
If you are new to the Linux command line, view and download our Linux Commands Cheat Sheet for easy reference.