VPSWala Blog

How to Find Files with the fd Command in Linux

May 25, 2025, Written by 0 comment

Ever tried finding a file in Linux and ended up scrolling forever through results you didn’t even want? The default find command is powerful, sure, but it’s also clunky. You have to remember weird flags, type long commands, and if you make a typo—boom—you start all over. It’s like searching for a needle in a digital haystack… blindfolded.

Meet fd: A Smarter, Simpler Alternative to find
That’s where fd comes in. Think of it as the cooler cousin of find—but way easier to hang out with. It’s faster, friendlier, and actually respects your .gitignore files. Whether you’re a Linux pro or just starting out, fd makes file searching feel like a breeze.


What Is the fd Command?

A Quick Overview of What fd Does
At its core, fd helps you find files and folders on your system. You type a simple command, and it shows you matching results in real time. It’s like Google Search but for your Linux machine.

How fd Differs from the Traditional find Command
Unlike find, which feels like it was built in the dinosaur days, fd is built for speed. It uses modern tech like multithreading, and it doesn’t make you memorize a thousand flags. You get smarter defaults, prettier output, and faster results. Less typing, more finding.

Why Developers and Sysadmins Love Using fd
People who live in the terminal love tools that just work—and fd does exactly that. Developers use it to search codebases. Sysadmins use it to manage servers. Even casual users pick it up quickly because it’s that intuitive.


Installing fd on Your Linux System

Checking if fd is Already Installed
Before you install anything, open your terminal and type:

fd --version  

If you see a version number, congrats—you’re good to go. If it says “command not found,” let’s fix that next.

Easy Ways to Install fd on Different Linux Distros
Installing fd is simple. Depending on your distro:

  • Ubuntu/Debian: sudo apt install fd-find
  • Fedora: sudo dnf install fd-find
  • Arch Linux: sudo pacman -S fd

Using Package Managers like apt, dnf, pacman, and Homebrew (for WSL users)
If you’re on Windows using WSL, just install Homebrew first, then:

brew install fd  

Done. Easy, right?


Getting Started with Basic fd Usage

Your First fd Command: Searching the Simple Way
Let’s say you’re looking for a file called “notes.txt”. Just type:

fd notes.txt  

Boom. You’ll see the file path if it exists.

How fd Automatically Ignores Hidden and Git Files
By default, fd skips hidden files and folders like .git. This keeps your results clean and useful. Want to include them? Add --hidden.

Running a Case-Insensitive Search Without Extra Flags
Searching for “README”? You don’t have to remember if it’s upper or lowercase. fd doesn’t care—uppercase, lowercase, or mixed—it finds it.


Understanding the Syntax: How fd Works Under the Hood

Breaking Down the Command Structure
fd keeps it simple. Basic format is:

fd [PATTERN] [PATH] [OPTIONS]  

The Role of Patterns, Paths, and Options

  • Pattern: What you’re looking for
  • Path: Where to look
  • Options: Add filters or extra behavior
    Example:
fd log . --extension=txt  

Finds all .txt files with “log” in the name.

Why You’ll Rarely Need Wildcards
No need for * or . tricks like in find. Just type part of the name, and it matches automatically. It’s smart like that.


Customizing Search Paths

How to Search Outside the Current Directory
Use a path after your pattern. For example:

fd report /var/log  

Searches “report” in /var/log.

Using Absolute vs. Relative Paths
Absolute: Starts from root (/home/user)
Relative: Starts from where you are (./docs)
Both work, depending on what you need.

Excluding Specific Directories from Your Search
Want to skip a folder? Use --exclude.

fd error . --exclude node_modules  

Filtering by File Type

How to Search Only for Files, Directories, or Symlinks
Use the -t flag:

  • Files: -t f
  • Directories: -t d
  • Symlinks: -t l

Common File Type Filters and When to Use Them
Looking only for folders?

fd config -t d  

Want only symbolic links?

fd link -t l  

Combining Filters for More Accurate Results
You can chain flags together:

fd test -t f --extension=sh  

Finds shell scripts with “test” in the name.


Using Regular Expressions with fd

Power Searching with Regex Patterns
Need to find files with numbers or special patterns? fd supports regex out of the box.

fd 'file[0-9]+\.log'  

How to Avoid Overcomplicating Regex
Regex is powerful but can get messy fast. Start simple and build up.

When to Use Simple Patterns Instead
For everyday use, stick to simple patterns like report, backup, or notes.


Running Commands on Search Results

Using fd with --exec to Automate Tasks
Want to act on each file? Use --exec:

fd error --exec rm {}  

Deletes every file with “error” in the name.

Real-Life Examples: Moving, Copying, or Deleting Found Files
Move all .jpg files to a new folder:

fd . --extension=jpg --exec mv {} ~/Pictures  

Safety Tips Before Running Destructive Commands
Always test first with --exec echo {} to see what files will be affected. One wrong move and files vanish.


Dealing with Hidden Files and Dot Directories

How to Include Hidden Files in Your Search
Just add --hidden.

fd config --hidden  

Searching Inside .git and Other Dot-Folders
Dot-folders are hidden by default. Use both --hidden and --no-ignore:

fd . --hidden --no-ignore  

Using the --hidden Flag Without Overloading Your Results
Combine --hidden with filters to keep results tidy. Otherwise, you’ll be buried in clutter.


Speed and Performance: Why fd is Lightning Fast

How fd Uses Multithreading for Faster Searches
fd searches multiple directories at once. It’s like sending out search dogs instead of one guy with a flashlight.

Comparing Performance with find
On big directories, fd can be 5x faster than find. It’s not magic—it’s just better code.

Tips to Make Your Searches Even Snappier

  • Use shorter paths
  • Use filters like --extension
  • Skip unnecessary folders with --exclude

Combining fd with Other Tools

Piping fd Output to xargs, grep, or fzf
Example:

fd log | xargs grep "error"  

Find log files, then search them for “error”.

Creating Custom Scripts with fd
You can bundle fd into shell scripts for repeat tasks like backups, cleanups, or file tagging.

Building Powerful One-Liners for File Management

fd temp --exec rm {} \;  

Deletes all files with “temp” in the name. One line. Boom.


Working with File Extensions

Searching by File Type or Extension Made Simple
Want all .md files?

fd --extension=md  

How to Include or Exclude Multiple File Types

fd . --extension=jpg --extension=png  

Includes both .jpg and .png.

Quick Examples for Developers and Designers

  • Developers: fd --extension=js
  • Designers: fd logo --extension=svg

Practical Everyday Use Cases

Finding Lost Files in Large Projects
Projects get messy. fd finds what you need fast—even inside nested folders.

Searching for Config Files in System Directories

fd conf /etc  

Handy for admins fixing server configs.

Cleaning Up Duplicate or Unused Files with Ease
Use fd to find temp, backup, or leftover files and clear them out.

Also Read: How do you redirect output in Linux?


Customizing Output for Clarity

Making Output More Readable with Colors and Formatting
fd color-codes by default. It’s easier on the eyes and quicker to scan.

Limiting Results with Flags Like --max-depth and --limit
Stop the flood with:

fd error --max-depth=2 --limit=10  

Saving Search Results to a File for Later Use

fd report > search-results.txt  

Dealing with Permissions and Access Issues

What to Do When fd Can’t Read a Directory
Sometimes you’ll see “Permission Denied.” Either skip it or run with sudo.

Using sudo with fd Safely

sudo fd config /root  

Be careful, especially if running destructive commands.

Skipping Over Permission Denied Errors Gracefully
By default, fd skips over these silently. It keeps the output clean.

Check out: How to Fix “passwd: Authentication token manipulation error” in Linux


Creating Aliases and Shortcuts for fd

Turning Long Commands into Easy Shortcuts
Add this to your .bashrc:

alias fda='fd --hidden --no-ignore'  

Setting Up Your .bashrc or .zshrc for Convenience
Put all your favorite fd tricks in your config file so they’re always ready.

Using Shell Functions for Custom Workflows
Create functions like searchlogs() to search logs with a click of a button.


Troubleshooting Common Mistakes

Why Your Search Isn’t Returning Results
Maybe it’s ignoring hidden files. Or the pattern is wrong. Or you’re in the wrong folder.

Common Flag Misuse and How to Fix It
Don’t mix up --type with --extension. Happens all the time.

Understanding Path Confusion and How to Avoid It
Double-check your current directory. Use pwd if you’re unsure.


Conclusion

Why fd Deserves a Spot in Your Linux Toolbox
It’s fast. It’s smart. It saves time and frustration. If you search files often, it’s a must-have.

Where to Go Next: Learning Even More Advanced Tricks
Explore chaining commands, building scripts, or using fd with cron jobs.

Final Tips for Making the Most of fd Every Day
Practice your most common searches. Save aliases. And don’t be afraid to experiment. fd is your terminal’s secret weapon.

vpswala Admin

Savita Sathe is an experienced writer and editor with over 10+ years of professional experience creating engaging content across industries. Whether it's blogs, whitepapers, website copy, emails, social media posts, or more. She develops effective hosting and tech content that helps brands connect with their audiences and achieve business goals.

Leave a reply

Your email address will not be published. Required fields are marked *