Kali Linux

How to Search Files and Folders in Linux Using the find Command

Handling large numbers of files is routine for Linux users, and that’s where the find command shines. It’s a dynamic tool that helps you search for files and directories based on name, type, modification date, size, permissions, and even content. Whether conducting audits, cleaning up old files, or troubleshooting, find ensures you locate exactly what you need, quickly and efficiently.

Command Syntax

find [location] [options] [expression]
  • location: Starting path for the search (e.g., /home/documents)
  • options: Filters for file type, name, size, permissions, etc.
  • expression: The pattern or property to match

Most Useful Options

OptionPurposeExample
-nameCase-sensitive name searchfind ~ -name “notes.txt”
-inameCase-insensitive name searchfind ~ -iname “notes.*”
-typeRestrict search to files (-f) or directories (-d)find /var/log -type f
-sizeFind files by size (e.g., +10M for over 10MB)find /tmp -size +100M
-mtimeSearch by last modified time (in days; -7 for past week)find . -mtime -7
-permFilter by permission bitsfind /etc -perm 755
-execRun another command on each matchfind . -name “*.bak” -exec rm {} ;
-emptyLocate empty files or directoriesfind ~/backups -empty
-maxdepthLimit how deep find searchesfind . -maxdepth 2 -type d

Practical Examples

1. Search for an Exact File Name

To find a file named budget.xlsx anywhere under /projects:

find /projects -name "budget.xlsx"

2. Search with a Partial Name or Pattern

Need any .pdf file in your Downloads?

find ~/Downloads -name "*.pdf"

3. Case-Insensitive Search

Not sure about the casing? Use -iname:

find /srv -iname "README*"

4. Limit Results by Size

Looking for log files larger than 50MB?

find /var/log -type f -size +50M

5. Search Files Modified in the Last Day

To find documents changed in the last 24 hours:

find ~/work -type f -mtime -1

6. Find and Delete Temporary Files

Remove .cache files under /tmp with a single command:

sudo find /tmp -type f -name "*.cache" -exec rm {} \;

7. List Only Directories

Generate a tree of folders within your Git repository:

find ~/git/myapp -type d

8. Find Empty Folders

Declutter unused empty folders from your Notes project:

find ~/notes -type d -empty

9. Search Files by Permission

Show all files with 600 permissions for security review:

find /etc -type f -perm 600

10. Search and Grep Content

Find all .conf files containing the word “server”:

find /etc -name "*.conf" -exec grep -l "server" {} \;

How find Works

The find command processes each directory and subdirectory from the specified location in real time. Unlike locate, which relies on a database, find actively checks all files right at search time, ensuring results always reflect the current state of your filesystem. You can combine expressions for advanced precision, and even execute actions instantly on found matches, such as copying, deleting, or changing permissions.

Why find Is Essential

With options for filtering by type, name, permissions, modification date, and actions, find is a powerhouse for system maintenance, bulk operations, security checks, and development workflows. Its flexibility saves time and reduces manual effort, making it an indispensable skill for every Linux user.

Read More: The shell

0xSnow

0xSnow is a cybersecurity researcher with a focus on both offensive and defensive security. Working with ethical hacking, threat detection, Linux tools, and adversary simulation, 0xSnow explores vulnerabilities, attack chains, and mitigation strategies. Passionate about OSINT, malware analysis, and red/blue team tactics, 0xSnow shares detailed research, technical walkthroughs, and security tool insights to support the infosec community.

Recent Posts

Set Up Nginx Server Blocks on Ubuntu 18.04: Host Multiple Sites

Nginx server blocks let you run more than one website on a single server. Each block…

11 hours ago

Install Tor Browser on Ubuntu 18.04: Anonymous Browsing Guide

Tor Browser is a modified version of Firefox that routes all your web traffic through the Tor…

12 hours ago

Install Vagrant on Ubuntu 18.04: Complete Setup Guide for Developers

Vagrant is a command-line tool that makes it easy to build and manage virtual machine environments.…

13 hours ago

Install VMware Tools on Ubuntu 18.04: Open VM Tools and ISO Guide

VMware Tools is a set of drivers and services that improves the performance of an Ubuntu…

13 hours ago

Install Apache Maven on Ubuntu 18.04: Stable or Latest Version

Java developers use project management tools to automate building their applications. Apache Maven is an open source…

13 hours ago

Install Mono on Ubuntu 18.04: C# Compiler and Runtime Guide

Running programs built for Microsoft's framework on a Linux system is easier than you think. Mono is…

2 days ago