Linux File Search Commands: The Complete Guide to Find, Locate, and FD

Need to quickly find files in Linux? Whether you’re looking for that config file you edited last week or trying to track down large files eating up disk space, Linux offers powerful search tools to help. This guide covers everything from basic commands to advanced techniques for finding files efficiently.

We’ll look at three main tools - the classic find command, the speedy locate, and the modern fd. Each has its strengths, and knowing when to use each one will make you much more productive.

Table of Contents

Understanding File Search Tools

Linux gives you several ways to search for files:

  • find - The traditional workhorse with tons of options
  • locate - Lightning-fast searches using a database
  • fd - A newer, more user-friendly tool

The Classic Find Command

The find command might be older, but it’s still the most flexible search tool in Linux. Yes, it’s slower than some alternatives, but its power makes up for that.

Basic syntax:

Terminalbash
find [path] [options] [expression]

Here are some everyday searches you’ll use:

Snippettext
# Find files by name
find /home -name "*.txt"

# Find files changed in the last 24 hours
find /var/log -mtime -1

# Find files bigger than 100MB
find / -size +100M

Advanced Find Features

Find really shines when you combine it with other commands:

Snippettext
# Find and remove all .tmp files
find . -name "*.tmp" -delete

# Find logs and compress them
find . -type f -name "*.log" -exec gzip {} \;

The Locate Command

When you need speed, locate is your friend. It searches a database instead of scanning your drives:

Snippettext
# Find a file quickly
locate filename.txt

# Update the database
sudo updatedb

The good:

  • Super fast searches
  • Easy to use
  • Searches everywhere

The not-so-good:

  • Database needs regular updates
  • Might show old results
  • Fewer search options than find

The Modern FD Tool

FD makes file searching more user-friendly with smart defaults:

Snippettext
# Get fd on Ubuntu/Debian
sudo apt install fd-find

# Basic search
fd pattern

# Find Python files
fd \.py$

What makes fd special:

  • Simple commands
  • Smart case handling
  • Color output
  • Built-in parallel searching
  • Ready-to-use regex support

Real-World Search Examples

Finding Config Files

Snippettext
# With find
find /etc -name "*.conf" -type f

# With fd
fd \.conf$ /etc

Finding Storage Hogs

Snippettext
# Find files over 1GB
find / -type f -size +1G

# Same search with fd
fd --type f --size +1G

Finding Recent Changes

Snippettext
# Last week's changes with find
find /home -type f -mtime -7

# With fd
fd --changed-within 7d

Speed Up Your Searches

Use locate for quick lookups When you don’t need the latest changes and just want fast results.

Limit how deep searches gofind . -maxdepth 2 -name “*.log”
fd –max-depth 2 \.log$

Search in parallel

Snippettext
# Let fd use more CPU cores
fd --threads 4 pattern

Working with Other Tools

Mix file search with other Linux tools for more power:

Snippettext
# Search inside files with ripgrep
fd -t f | xargs rg "search pattern"

# Back up found files
fd \.conf$ -x cp {} {}.backup

Common Problems and Fixes

  1. Permission Issues
Terminalbash
# Use sudo when needed
sudo find / -name "system.log"
  1. Special Character Problems
Terminalbash
# Quote or escape special chars
find . -name "*.txt" -o -name "*.log"
  1. Files with Spaces
Terminalbash
find . -name "* *" -type f
fd '. +.+'

Smart Search Habits

  1. Pick the Right Tool
  • find for complex searches and actions
  • locate for quick system searches
  • fd for simpler, faster searches
  1. Think About Performance
  • Keep searches focused
  • Use locate’s database for speed
  • Try parallel processing for big jobs
  1. Stay Safe
  • Be careful with recursive commands
  • Double-check before using -exec or -delete
  • Watch out for permission issues

Wrapping Up

Knowing how to search for files effectively in Linux means understanding these different tools. While find remains the most powerful, locate and fd offer great alternatives for specific needs. Mix and match these tools based on what you’re trying to do.

Want to learn more about handling files in Linux? Check out our Linux File System Commands: Essential Guide for Beginners.

Try these tools yourself and see which ones work best for you. Remember - sometimes using a combination of tools is the fastest way to get what you need.

whoami

I'm Stefan, a senior software engineer. I build with AI agents every day, and I show how: my workflows, the new tools I test and what breaks along the way. I build apps like XPmetric and ProofSwap, and my own tooling too, like the AI Coding Orchestrator and the pipeline that edits my videos. I started in 2016 with Linux, cybersecurity and Python tutorials. Then AI changed how I work, so the videos changed too. Still a Linux nerd at heart.

More about me