Why the fd Command Beats find
The regular find command works fine, but its syntax can be annoying. You have to remember flags like -iname or -type f, and the output is plain text with no color. I spent years typing find . -iname "*something*" before I switched.
fd fixes these problems. It uses a simple pattern-based syntax, respects .gitignore by default, and colorizes output. It is also noticeably faster because it is written in Rust. If you have used ripgrep (which we covered in an earlier article), fd follows the same philosophy. Sensible defaults, fast execution, clean output.
The fd command is not meant to replace find for everything. For complex scripted operations, find still wins. But for everyday file hunting on the command line, the fd command is the better tool. It is the kind of tool that makes you wonder why you put up with the old way for so long.
Installing fd
Installation depends on your system. On Debian and Ubuntu, you need to grab the release from GitHub because fd is not in the default repos on older versions. But once it is installed, the fd command works the same on every distro.
# Debian/Ubuntu (add repo first)
sudo apt install fd-find
# On some systems the binary is called 'fdfind'
# Create an alias if you want just 'fd'
alias fd='fdfind'
On Arch, it is straightforward:
sudo pacman -S fd
On macOS with Homebrew:
brew install fd
You can also download a static binary from the GitHub releases page and drop it in your PATH. No dependencies needed.
1. Basic File Search with the fd Command
The most basic use of the fd command is searching for a file by name. Just pass the pattern and it recursively searches the current directory.
fd notes
That finds every file or directory with “notes” in the name. Compare this to find:
find . -iname '*notes*'
Which one would you rather type? The fd command also colorizes directories in blue, executables in green, and files in white. You can spot what you need at a glance. That is the whole point. A search tool should show you results, not make you parse text.
2. Search in a Specific Directory with fd
Pass a directory path as the second argument. This searches /etc for anything related to “nginx”:
fd nginx /etc
I use this constantly when I forget where a config file lives. No more find /etc -type f -name "*nginx*" 2>/dev/null. The fd command handles hidden directories and permission errors gracefully without extra flags. It is one of those small wins that adds up over a day of work.
3. Filter by File Type
Use -t to filter by type. The common values are f for files, d for directories, and l for symlinks.
# Find only directories named cache
fd -t d cache
# Find only Python files
fd -e py
# Find only executable files
fd -t x
The -e flag is shorthand for extension filtering. fd -e py is much cleaner than find . -name "*.py" and the output is colorized automatically.
4. Include Hidden and Ignored Files
By default, fd skips hidden files (dotfiles) and respects .gitignore. This is usually what you want, but sometimes you need to see everything.
# Include hidden files
fd -H config
# Include both hidden and ignored files (gitignored too)
fd --no-ignore -H config
This is one of my favorite features. With find, you need -name ".*" to catch dotfiles, and there is no built-in gitignore support at all. The fd command handles this out of the box. It just works the way you expect.
5. Execute Commands on Results
The -x flag runs a command on each result. This is incredibly useful for batch operations.
# Count lines in every Python file
fd -e py -x wc -l
# Search for a string in all markdown files (works with ripgrep too)
fd -e md -x grep "TODO"
# Remove all .log files interactively
fd -e log -x rm -v
The -X variant runs the command once with all results as arguments. Same syntax as find -exec, but easier to remember.
# Run chmod on all shell scripts at once
fd -e sh -X chmod +x
6. Search File Contents (Bonus)
This is the killer combination. Use fd to find files and pipe them to xargs or ripgrep to search contents.
# Find all markdown files and search for "TODO" in them
fd -e md | xargs grep -l "TODO"
# Better yet, use ripgrep directly
rg "TODO" --type md
If you have ripgrep installed, it handles this natively. But when you need file-type filtering with content searching, piping the fd command into other tools is fast and intuitive. It is a great example of the Unix philosophy. One tool does one thing well, and you connect them with pipes.
7. Use fd with fzf for Interactive Search
This is where fd really shines. Combined with fzf, it creates an interactive file search that feels like magic.
# Interactive file search with preview
fd --type f | fzf --preview 'bat {}'
# Open the selected file in vim
vim "$(fd --type f | fzf)"
The --preview flag shows a preview of each file as you scroll. If you have bat installed (we have a guide on that too), the preview is syntax-highlighted. I use this workflow dozens of times a day.
Common Options Reference
Here is a quick cheat sheet for the most useful fd command options. Keep this handy while you learn:
fd [pattern] [path] # Basic search
fd -t f [pattern] # Files only
fd -t d [pattern] # Directories only
fd -e EXT [pattern] # By extension
fd -H [pattern] # Include hidden files
fd -s [pattern] # Case-sensitive search
fd -E pattern [glob] # Exclude pattern
fd -x CMD # Run CMD on each result
fd -X CMD # Run CMD with all results
fd --changed-within 1d # Modified in last day
Why I Stick with fd
I switched to fd two years ago and never looked back. The syntax is simpler, the output is readable, and it respects your project conventions out of the box. It is one of those tools that does not change how you work. It just removes friction from something you do all day.
If you are still using find for everyday searches, give the fd command a try for a week. Install it, alias it, and use it for everything. You will probably find yourself typing fd without thinking about it by day three. That is the real test of a good tool. It becomes invisible.
For more details, check out the official GitHub repository and the fd man page. Both are excellent resources. And if you want to pair fd with other modern CLI tools, our fzf tutorial and ripgrep guide cover the tools that work best alongside it.