Tech Zone

How to Use Linux Find Command to Search for Files

8 Mins read
Linux Find Command

Have you ever struggled to locate a file in Linux? Whether it’s a missing configuration file, an application log, or an old script buried deep within the filesystem, manually searching through directories can be time-consuming.

That’s where the find command in Linux comes in. As one of the most powerful file-searching utilities available, it helps you quickly locate files and directories based on criteria such as name, extension, size, ownership, permissions, and modification date.

In this guide, you’ll learn how to find file in Linux using real-world examples. We’ll start with the basics before moving into more advanced search techniques that make file management much easier.

What Is the Find Command in Linux?

The find command in Linux is a command-line utility that searches for files and directories within a specified location.

Unlike graphical file explorers that rely mainly on filenames, the Linux find command allows you to search using multiple criteria simultaneously. You can narrow your search based on file type, size, permissions, owner, modification date, or even perform actions on the files it finds.

As Linux remains one of the most widely used platforms among developers and cloud environments, file-searching tools like find are essential for efficient system administration and daily operations.

According to the Stack Overflow Developer Survey 2025, Linux and Linux-based environments continue to be widely used by professional developers worldwide.

Think of it as a search engine for your Linux filesystem. Instead of manually opening one directory after another, you simply tell Linux what you’re looking for, and it does the heavy lifting.

Some common use cases include:

  • Finding configuration files
  • Searching for log files
  • Locating recently modified documents
  • Identifying large files consuming disk space
  • Finding files owned by a specific user
  • Cleaning temporary or old files

The flexibility of this command is what makes it one of the most frequently used Linux utilities.

What is the Basic Syntax?

Before exploring examples, it’s helpful to understand how the command is structured.

find [starting_directory] [options] [search_expression]

Each part has a specific purpose.

Component  Description 
find  Starts the command 
Starting directory  Specifies where the search begins 
Options  Defines search behavior 
Search expression  Tells Linux what to search for 

Here’s a simple example:

find /home -name “notes.txt”

This command tells Linux to start searching inside the /home directory and return every file named notes.txt.

The search also includes every subdirectory inside /home, making it extremely useful when you don’t remember exactly where a file is stored.

Linux Find Command Cheat Sheet: Most Common Searches

Before exploring practical examples, use this quick cheat sheet as a handy reference for the most common Linux find command searches.

Task  Command 
Find a file by name  find /home -name “file.txt” 
Case-insensitive search  find /home -iname “file.txt” 
Find only files  find /home -type f 
Find only directories  find /home -type d 
Find files by extension  find . -name “*.pdf” 
Find files larger than 500 MB  find / -type f -size +500M 
Find files modified in the last 7 days  find /home -type f -mtime -7 
Find files owned by a user  find /home -user john 
Find files with 777 permissions  find / -type f -perm 777 
Delete temporary files  find /tmp -type f -name “*.tmp” -delete 

Common Find Command Examples in Linux

Now that you understand the basic syntax and commonly used options, let’s explore some practical examples of the Linux find command:

1. Find File in Linux by Name

One of the most common applications of the Linux find command is searching for files by name.

If you already know the exact filename, simply use the -name option.

find /home -name “project.docx”

If Linux finds the file, it’ll return the complete file path.

Example output:

/home/ZNet/Documents/project.docx 

The important thing to remember is that -name performs a case-sensitive search.

That means these are considered different files:

  • Project.docx
  • project.docx
  • PROJECT.docx

If the capitalization doesn’t match exactly, Linux won’t return any results.

2. Search a File in Linux Without Knowing the Exact Name

In real-world scenarios, you often remember only part of a filename.

Maybe you remember it contains the word “backup.”

Or perhaps you know it ends with “.conf.”

This is where wildcards become incredibly useful.

For example:

find /home -name “*backup*”

This command searches for every file containing the word backup.

Possible results might include:

  • daily_backup.sql
  • backup-config.conf
  • server_backup.zip
  • backup_old.tar.gz

Similarly, if you’re looking for every configuration file:

find /etc -name “*.conf”

Linux returns every file ending with .conf.

The use of wildcards saves time and reduces reliance on exact filenames.

3. Ignore Letter Case During Searches

Linux distinguishes between uppercase and lowercase characters. Sometimes that’s helpful. Sometimes it’s frustrating. 

Imagine searching for:

find /home -name “resume.pdf”

If the actual file is named:

Resume.pdf

Linux won’t find it.

Instead, use the -iname option. 

find /home -iname “resume.pdf”

The search now ignores capitalization and returns matching files regardless of how they’re named.

This small option makes a huge difference when searching files created by different users or downloaded from various sources.

4. Search Only Files

By default, the find command searches everything.

  • Files
  • Folders
  • Links

Sometimes you only want actual files.

The -type option helps filter results.

find /home -type f

Here, f stands for file.

To search only text files:

find /home -type f -name “*.txt”

Likewise, searching only PDF files becomes straightforward.

find /home -type f -name “*.pdf”

This approach is especially useful when you’re searching project documentation, reports, or log files.

5. Search Only Directories

Need to locate a folder instead?

Replace f with d.

find /var -type d -name “logs”

This command ignores regular files and searches only for directories named logs.

It’s particularly useful when working with application deployments, web servers, or containerized environments where multiple directories have similar names.

6. Find Files by Extension

Searching by extension is one of the fastest ways to narrow your results.

For example, to locate every shell script:

find . -name “*.sh”

Python files:

find . -name “*.py”

Java files:

find . -name “*.java”

Compressed archives:

find . -name “*.tar.gz”

Instead of scanning hundreds of unrelated files, Linux immediately filters results based on the extension.

7. Search Files by Size

Another powerful feature of the Linux find command is the ability to search files based on their size.

Suppose your server storage suddenly starts filling up.

One of the first things you’ll want to identify is unusually large files.

To search files larger than 500 MB:

find / -type f -size +500M

To locate files smaller than 1 MB:

find /home -type f -size -1M

You can also search using kilobytes (k) or gigabytes (G).

For example:

find / -size +2G

This command quickly identifies files larger than 2 GB, making storage cleanup significantly easier.

Why Every Linux User Should Learn the Find Command

Many Linux users start with simple commands like ls and cd, but as systems grow larger, those commands alone aren’t enough.

The find command in Linux is one of those essential utilities you’ll use regularly. Whether you’re troubleshooting an application, managing a server, or organizing files, it helps you locate exactly what you need quickly and efficiently.

And that’s just the beginning. The advanced techniques covered next will help you narrow searches even further, automate tasks, and manage files more effectively.

Advanced Find Command Examples in Linux

Beyond basic searches, the Linux find command lets you filter files by date, owner, permissions, and more. You can also combine multiple conditions, execute commands on matching files, and safely delete unwanted data.

1. Find Files by Modification Date

Sometimes, you don’t remember a file’s name but know when you last worked on it. The find command makes it easy to search files based on their modification time.

For example, to find files modified within the last seven days:

find /home -type f -mtime -7

Here’s what the -mtime option means:

  • -7 searches for files modified within the last seven days.
  • 7 finds files modified exactly seven days ago.
  • +7 returns files that haven’t been modified for more than seven days.

This filter is particularly useful when you’re reviewing recent project changes, troubleshooting application issues, or cleaning up outdated files.

2. Search Files by Owner

In multi-user Linux environments, knowing who owns a file can make troubleshooting much easier.

To find every file owned by a specific user, use the -user option.

find /home -user john

Replace john with the appropriate username.

This command is especially helpful for system administrators managing shared servers or investigating permission-related issues.

3. Search Files by Permission

File permissions play a critical role in Linux security. If a script isn’t executing or a user can’t access a file, checking permissions is often the first step.

To search for files with 777 permissions:

find / -type f -perm 777

Similarly, to locate files with read-only permissions:

find / -type f -perm 444

Searching by permissions helps identify security risks, incorrect configurations, and files that may require access changes.

4. Combine Multiple Search Conditions

One of the biggest strengths of the Linux find command is that you can combine multiple filters into a single search.

Suppose you want to find every PDF file larger than 10 MB.

find /home -type f -name “*.pdf” -size +10M

Or perhaps you’re searching for log files modified within the last two days.

find /var/log -type f -name “*.log” -mtime -2

The use of multiple filters improves search accuracy by narrowing results, even on servers with thousands of files.

5. Execute Commands on Search Results

File searches are often followed by tasks that require actions to be executed on each matching file.

The -exec option lets you do exactly that.

For example, suppose you want to display detailed information for every shell script.

find . -name “*.sh” -exec ls -l {} \;

You can also use -exec to change permissions, move files, compress logs, or run custom scripts.

Because this option executes commands directly, always double-check your search criteria before running it on important systems.

6. Delete Files Safely Using the Find Command

The find command can also remove files that meet specific conditions.

For instance, to delete temporary files ending with .tmp:

find /tmp -type f -name “*.tmp” -delete

Before using the -delete option, it’s a good practice to run the same search without it.

find /tmp -type f -name “*.tmp”

Review the results first. Once you’re sure the correct files are listed, add -delete.

This simple precaution can help prevent accidental data loss.

Common Mistakes to Avoid When Using the Find Command

The Linux find command is powerful, but small mistakes can lead to unexpected results.

Here are a few common ones:

  • Searching from the Wrong Directory

Starting your search from the root (/) scans the entire filesystem. This may take longer than necessary.

Whenever possible, begin from the directory where the file is most likely to exist.

  • Forgetting Case Sensitivity

The -name option is case-sensitive.

If you’re unsure about capitalization, use -iname instead.

  • Using Broad Wildcards

A command like:

find / -name “*”

returns every file and directory on the system.

While technically correct, it’s rarely useful and can slow down the search significantly. Use more specific patterns whenever possible.

  • File Deletion Without Verification

Never combine find with -delete until you’ve confirmed the search results.

Taking an extra few seconds to review the output can save hours of recovery work.

Best Practices for Using the Linux Find Command

To get the best results, keep these practical tips in mind:

  • Start your search from the most relevant directory.
  • Use filters such as file type or extension to narrow results.
  • Prefer -iname when you’re unsure about capitalization
  • Combine multiple search conditions for greater accuracy.
  • Review search results before deleting or modifying files.
  • Learn commonly used options instead of memorizing every available flag.

These habits make your searches faster, safer, and easier to manage.

Final Thoughts

The find command in Linux is one of the most useful tools for locating and managing files efficiently. From searching by name and extension to filtering by size, permissions, ownership, and modification date, it helps simplify everyday file management and system administration tasks.

As you become familiar with its options and filters, you’ll be able to find files faster, troubleshoot issues more effectively, and automate routine tasks with confidence.

Looking to optimize your Linux infrastructure? ZNet Technologies offers secure cloud hosting, Linux VPS hosting, managed services, and scalable infrastructure solutions to help businesses build high-performing Linux environments. Explore our solutions to support your growing IT needs.

Related posts
BusinessMarketingTech Zone

A Beginner’s Guide to Wati: WhatsApp Business Automation Tool

5 Mins read
Businesses today need faster ways to connect with customers. WhatsApp has become a key communication channel supported by modern business automation tools. As per…
Tech Zone

Best 11 Free AI Tools to Simplify Your Daily Work-Life in 2026

4 Mins read
Think about how much of your workday goes into replying to emails, preparing content, attending meetings, and managing data. These everyday tasks…
Ecommerce WebsiteMarketingTech Zone

What is ZNetLive Marketplace? Everything you need to know about

4 Mins read
Imagine a world where buying software is as seamless as shopping online – no endless vendor negotiations, no delays, just instant access…