7 Ways to Find a File in Linux

How to Find a File in Linux (7 Methods)

Your Linux command-line interface (CLI) likely has many native options for how to find a file in Linux in all directories. You can have Linux find text in files and metadata. You can quickly list files that were changed within a specific time frame, useful for security information and event management (SIEM). There are also graphical applications for Linux systems with a desktop environment such as GNOME or Cinnamon.

While there are many programs that can be used to find a file in Linux, not all are best suited for everyone’s common usage. They’re sorted based on how much you can do with the program.

Terminal Applications to find Files and Directories

Find Files in Linux

find is the most powerful tool on this list to find a file in Linux. Starting off, to view all regular and hidden files in a directory (and its sub-directories):

find .

“.” means to start from the current directory.
“~” means to start from the current user home directory.
“/” means to start from the system root directory.

find /var/www/html/
find public_html/

The results will look similar to the ls command. You can add | less at the end to easily scroll through results.

To narrow your search, you could use grep. However, the find command includes flexible options to provide the results you need.

To view files and directories that start with “backup” (case-sensitive):

find . -name "backup*"

Use -iname instead for a case-insensitive search.

To filter results to only regular files, add -type f:

find . -type f -iname "backup*"

To only list directories, add -type d:

find . -type d -iname "backup*"

You can filter results by size, under (-) or over (+) a specified number of kilobytes (k), megabytes (M), or gigabytes (G). Continuing with our examples above, to only show files over 1 megabyte starting with “backup”:

find . -type f -size +1M -iname "backup*"

You can combine search filters to narrow down results with -and, -or, and -not. To find files above 10 megabytes that are not zip or gz files:

find . -type f -size +10M -not -iname "*zip" -and -not -iname "*gz"

To search by permissions, use -perm followed by the permissions set:

find . -perm 777

Execute commands with search results by adding -exec, the command to execute against the results, and {} \; at the end. The example below creates a sha512 checksum for all “backup” files found.

find -iname "backup*" -exec sha512sum {} \;

You can search for files accessed during, before (-), or after (+) a specified time frame. To list files accessed within the last 24 hours:

find . -atime -1

Within 60 minutes:

find . -amin 60

To view files in your home folder modified over 365 days ago:

find . -mtime +365

Within 60 minutes:

find . -mmin 60

To print output to the end of a text file, you can use >> file.txt or add the following to the end of your query:

-fprint newfile

Locate Files in Linux

The locate command is sometimes faster because it uses a pre-existing database updated by a cron job. To update the locate database manually:

sudo updatedb

Unlike the find command, locate searches the entire system by default. Therefore, searching for files and directories including “backup” in the name will return results from all directories. The results use the --wholename option by default.

locate backup

To search only the base name, instead of the entire file path, for a query:

locate -b '\backup'

You can use -i for a case insensitive search. In the example below, results would include files and directories starting with “backup” and “Backup.”

locate -i "*\backup"

mlocate takes over locate commands to find a file in Linux if both are installed. Unlike locate, mlocate only displays files accessible by the user.

Find file paths to executables with commands like which and whereis.

Graphical Applications to Find Files and Directories


Using Catfish to find a file in Linux

Catfish is a graphical search application to find a file in Linux desktop systems. It is often included in XFCE desktop environments (DEs). You can search directories by:

  • File type 
  • Date modified
  • File contents


Using KFind to find a file in Linux

KFind is a more advanced graphical search application native to KDE and the Konqueror file manager. The software allows you to filter searches by:

  • File type 
  • Date modified
  • File contents
  • File metadata
  • Date created
  • File owner
  • File size

Learn more about managing headless Linux systems with our Cloud Server Hosting Product Guide.

If you don’t need cPanel, don't pay for it. Only pay for what you need with our Cloud VPS solutions

check markCentOS, Debian, or Ubuntu    check markNo bloatware    check markSSH Key management made easy

Jacqueem Content Writer I

Technical writer focused on cybersecurity and musicianship.

More Articles by Jacqueem

Was this article helpful? Let us know!