fd — fast find
💬 "fd command"
fd is a fast and concise file search tool that replaces find. The command structure is simple and it excludes hidden files by default, resulting in clean output.
Instead of find's complex -name/-type options, it searches with a single intuitive pattern.
- Concept: Quickly finds files and directories that match the pattern.
- find replacement: Performs the same task with much shorter commands.
- Hidden files excluded: Excludes hidden files like .git by default.
- Regex support: Regex search is also possible with the -e option.
Installation and Download
fd can be installed via package managers or cargo.
| Environment | Command |
|---|---|
| Ubuntu / Debian | sudo apt install fd-find |
| Fedora / RHEL | sudo dnf install fd-find |
| Arch | sudo pacman -S fd |
| macOS (brew) | brew install fd |
| Rust cargo | cargo install fd-find |
| Binary download | github.com/sharkdp/fd/releases |
To verify the installation, use fd --version or fdfind --version. On Debian/Ubuntu, it is fdfind.
Commonly Used Options
| Option | Description |
|---|---|
| -e ext | Filters by extension |
| -t f | Files only, -t d is directories only |
| -H | Includes hidden files |
| -i | Ignores case |
| --max-depth N | Limits the search depth |
3 Essential Command Combinations
fd -e conf— Quickly search for conf files onlyfd -e py -t f /var/www— Find Python files onlyfd -H -e log— Search for log files including hidden ones
💬 "Show me an example of quickly finding configuration files on a live server"
We've outlined a common scenario encountered on live servers in a step-by-step manner.
Step 1: Verify Installation
Check if it is installed.
fdfind --version || fd --version || sudo apt install -y fd-find
Step 2: Search for conf Files
Find conf files in the web root.
fd -e conf /var/www/html
Step 3: Files with a Specific Name
Find nginx-related files across the entire system.
fd -H nginx /etc
Live Execution Example
This shows the result of searching for conf files in the web root with fd. A clean list is displayed immediately.
Live server in operation
In Practice, It's Used Like This
1. Finding Files in a Specific Project
Scenario — Find the entry point of an old project.
fd -e py -t f main
Result — A list of main.py files is displayed immediately.
Key point — Using -t f to distinguish files from directories makes the results clean.
2. Collecting Log Files
Scenario — Collect logs scattered across multiple directories at once.
fd -e log /var/log | head -10
Result — A list of log file paths is displayed.
Key point — It's much shorter and easier to read than find.
Live Execution Example
This shows the result of searching for nginx-related files across the entire system.
!fd command execution result 2
Live server in operation
Things to Note
- On Debian/Ubuntu, the command name is fdfind.
- Hidden files are excluded by default. To include them, use -H.
- If you need to execute directly instead of find's -exec, use it with xargs.
- If you provide an absolute path pattern, it will only search under that path.
Source (HTML): https://games.aidebatehub.com/programs/linux/modern/fd.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments