How to Use fd as a Faster Replacement for the find Command on Ubuntu Linux

The find command is one of the most powerful tools in the Linux terminal for locating files and directories. However, its syntax is notoriously unintuitive. A simple search like “find all Python files in the current directory” requires typing find . -name "*.py" -type f, and more complex searches with multiple criteria, exclusions, and depth limits become verbose multi-line commands that are easy to get wrong.

fd is a modern, fast replacement for find written in Rust. It uses sensible defaults, a simplified syntax, and produces colour-coded output. In most common use cases, fd requires fewer characters to type, runs significantly faster than find, and provides more readable results.

How to Install fd on Ubuntu

fd is available in the default Ubuntu repositories:

sudo apt update && sudo apt install fd-find

Important note for Ubuntu users: Due to a package naming conflict, the fd binary on Ubuntu is installed as fdfind instead of fd. To use it as fd, create an alias:

alias fd='fdfind'

Add this line to your ~/.bashrc file and run source ~/.bashrc to make it permanent.

Basic Usage

fd’s syntax is dramatically simpler than find. The most basic usage is:

fd pattern

This searches the current directory (and all subdirectories) for files and directories whose names contain the specified pattern. For example:

fd readme

This finds all files and directories containing “readme” in their name (case-insensitive by default). Compared to find, which would require:

find . -iname "*readme*"

Sensible Defaults That Save Time

fd differs from find in several important ways, all of which are improvements for typical daily use:

  • Case-insensitive by default: fd searches case-insensitively unless your pattern contains an uppercase letter. If you type fd readme, it matches “README”, “Readme”, and “readme”. If you type fd README, it only matches “README”.
  • Ignores hidden files and directories: fd skips files and directories starting with a dot (like .git, .env, .config) by default. This avoids flooding your results with thousands of hidden configuration files.
  • Respects .gitignore: If you are inside a Git repository, fd automatically ignores files listed in .gitignore. This means build output directories (like node_modules, __pycache__, dist) are excluded from results without any extra flags.
  • Colour-coded output: Results are colour-coded by file type, making it easy to distinguish directories, files, and symbolic links at a glance.
  • Regex by default: Patterns are treated as regular expressions by default, giving you powerful matching without special flags.

Common Use Cases

Find Files by Extension

fd -e py

This finds all files with the .py extension. No quotes, no wildcards, no -name flag. Compare with find: find . -name "*.py" -type f.

You can combine multiple extensions:

fd -e py -e js -e ts

This finds all Python, JavaScript, and TypeScript files in one command.

Find Only Directories

fd -t d config

The -t d flag restricts results to directories only. This finds all directories containing “config” in their name.

Find Only Files

fd -t f config

The -t f flag restricts results to files only.

Search a Specific Directory

fd pattern /path/to/search

By default, fd searches the current directory. Add a path as the second argument to search elsewhere.

Include Hidden Files

fd -H pattern

The -H flag includes hidden files and directories in the search results.

Include Gitignored Files

fd -I pattern

The -I flag includes files that would normally be excluded by .gitignore rules.

Limit Search Depth

fd -d 2 pattern

The -d flag limits how many directory levels deep fd searches. -d 1 searches only the current directory (no subdirectories), -d 2 searches one level of subdirectories, and so on.

Using fd with Other Commands

fd integrates seamlessly with other terminal commands through pipes and command substitution:

Delete All Files Matching a Pattern

fd -e log -x rm

The -x flag executes a command on each result. This finds all .log files and deletes them. Be cautious with this — consider adding --dry-run first to see what would be affected.

Count Files by Extension

fd -e py | wc -l

Pipes the results to wc -l to count the number of Python files.

Open All Matching Files in an Editor

fd -e py -x code

Opens every Python file in Visual Studio Code.

Speed Comparison: fd vs find

fd is significantly faster than find in most scenarios because:

  • It uses parallel directory traversal, scanning multiple directories simultaneously across CPU cores.
  • It skips ignored files early, reducing the number of file system operations.
  • It is written in Rust, which compiles to highly optimised native code.

In large repositories with thousands of files (like the Linux kernel source tree or a large Node.js project), fd can be 5 to 10 times faster than find.

fd vs find: Syntax Comparison

Task find fd
Find by name find . -iname “*readme*” fd readme
Find by extension find . -name “*.py” -type f fd -e py
Find directories find . -type d -name “*config*” fd -t d config
Limit depth find . -maxdepth 2 -name “*.js” fd -d 2 -e js
Execute command find . -name “*.log” -exec rm {} \; fd -e log -x rm

Setting fd as a Permanent Alias

Add the following to your ~/.bashrc or ~/.zshrc:

alias fd='fdfind'
alias find='fdfind'

The second alias is optional — it replaces find entirely with fd. Only do this if you are comfortable with fd’s syntax and do not rely on find-specific features in scripts. Note that fd does not support every find option, so existing scripts that use advanced find flags may need to continue using the original find command.

fd is part of a new generation of Rust-based terminal tools (alongside eza, bat, and ripgrep) that are dramatically improving the daily Linux command-line experience. Once you start using fd, the verbose syntax of the traditional find command feels unnecessarily painful.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.