0% found this document useful (0 votes)
2 views

How to Find File in Linux

The document provides a comprehensive guide on how to find files in Linux using both command-line and graphical user interface (GUI) methods. It details various command-line tools such as find, locate, and grep, along with their syntax and examples, as well as instructions for using built-in file managers and the Catfish search application. The article aims to equip users with practical techniques for efficient file searching in Linux environments.

Uploaded by

Zac Ing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

How to Find File in Linux

The document provides a comprehensive guide on how to find files in Linux using both command-line and graphical user interface (GUI) methods. It details various command-line tools such as find, locate, and grep, along with their syntax and examples, as well as instructions for using built-in file managers and the Catfish search application. The article aims to equip users with practical techniques for efficient file searching in Linux environments.

Uploaded by

Zac Ing
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

https://phoenixnap.

com/kb/find-file-linux

Home » KB » SysAdmin » How to Find File in Linux


How to Find File in Linux
By Marko Aleksic Published: April 17, 2025
Topics: Commands, 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.

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] Copy

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" Copy

The output shows the full path to the 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" Copy

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

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 Copy

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.

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]" Copy

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

ls examples | grep "image" Copy

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] Copy

Add the -i option for case-insensitive searches:

locate -i [filename] Copy

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 Copy

The output returns multiple matches:

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

locate -r /[filename]$ Copy

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.

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.

You might also like