How to Find File in Linux

By
Marko Aleksic
Published:
April 17, 2025
Topics:

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.

How to find a file in Linux.

Find File in Linux via Command Line

Command-line file searches in Linux commonly use the find command. However, other utilities like locate and grep offer alternative search functionalities.

The sections below show the most practical ways to find a file in Linux.

find Command

The find command searches for files and directories on a specified path using the criteria in the command arguments. Below is the basic command syntax:

find [options] [path] [expression]

For example, type the following command to find a file named image1.png located in the home directory (or one of its subdirectories):

find /home -name "image1.png"

The output shows the full path to the file.

The output of the find command showing the full path to the image1.png file.

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:

find /home/marko/examples -name "*.png"

The output shows a list of files that match the selected criteria.

The output of the find command showing the full path to all the files with the PNG extension.

find and grep Command

The grep command enables users to search for text patterns in files. Combined with find, it helps search for files based on their content.

Type the following command to list files that contain the specified string:

find [path] -type f -exec grep "[string]" '{}' \; -print

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

For each file that matches the criteria, the output shows the line where the string appears, followed by the file path.

Using grep to search for text patterns in the files.

ls and grep Command

The grep command can also look for matches in filenames if a list of filenames is provided. Use the following syntax to pipe the output of the ls command to grep:

ls [path] | grep "[search_term]"

For instance, search the examples directory for the files with image in the filename:

ls examples | grep "image"
Using grep to look for filenames.

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.

Use the following syntax to search for files with locate:

locate [filename]
Using the locate command to find a file.

Add the -i option for case-insensitive searches:

locate -i [filename]
The case-insensitive search with locate.

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:

locate ~/examples/image

The output returns multiple matches:

The output of locate shows multiple matches.

Use the -r option to force locate to return only exact matches:

locate -r /[filename]$

Find File in Linux via GUI

Different Linux distributions come with different graphical interfaces and tooling. The sections below show how to search using the built-in file manager and the Catfish search application.

Built-in File Manager

Most Linux distributions include file managers with integrated search features. The following example shows how to search for a file in GNOME Files (Nautilus):

1. Open the application.

2. Select the magnifying glass icon in the top-right corner. The search box appears.

3. Type the search term into the search box and press Enter.

The search results appear in the window.

The GNOME Files showing the file search results.

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.

A list of matches in the main window pane of the Catfish application.

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.

Was this article helpful?
YesNo