cli-tools
📋 Copy All fd Commands
📄 Generate fd PDF Guide
fd - Fast and User-Friendly Find Alternative Cheatsheet
Installation
Platform
Command
Ubuntu/Debian
sudo apt install fd-find (binary: fdfind)
Arch Linux
sudo pacman -S fd
Fedora/RHEL
sudo dnf install fd-find
Alpine Linux
apk add fd
macOS (Homebrew)
brew install fd
macOS (MacPorts)
sudo port install fd
Windows (Scoop)
scoop install fd
Windows (Chocolatey)
choco install fd
Windows (Winget)
winget install sharkdp.fd
Cargo (All platforms)
cargo install fd-find
Snap
sudo snap install fd
Note : On Debian/Ubuntu, create symlink: ln -s $(which fdfind) ~/.local/bin/fd
Basic Commands
Command
Description
fd filename
Search for files/directories matching "filename"
fd pattern /path
Search for pattern in specific directory
fd -e txt
Find all files with .txt extension
fd -e js -e ts
Find files with multiple extensions (.js or .ts)
fd -t f pattern
Find only files (not directories)
fd -t d dirname
Find only directories
fd -t x
Find only executable files
fd -t l
Find only symbolic links
fd -s Pattern
Case-sensitive search (default is case-insensitive)
fd -d 3 pattern
Limit search depth to 3 levels
fd -H pattern
Include hidden files in search
fd -I pattern
Don't respect .gitignore rules
fd -a pattern
Show absolute paths instead of relative
fd -l pattern
Show detailed listing (like ls -l)
fd -0 pattern
Use null separator (for piping to xargs -0)
Advanced Usage
Command
Description
fd '^test.*\.js$'
Use regex pattern (files starting with "test", ending with .js)
fd -g '*.{js,ts}'
Use glob patterns instead of regex
fd -F 'exact.string'
Fixed string search (no regex interpretation)
fd -E node_modules -E '*.tmp' pattern
Exclude specific patterns from search
fd --no-ignore pattern
Don't use .gitignore, .fdignore, or .ignore files
fd -L pattern
Follow symbolic links during search
fd --changed-within 2d
Files modified within last 2 days
fd --changed-before 30d
Files not modified in last 30 days
fd --size +100m
Files larger than 100MB
fd --size +10m --size -100m
Files between 10MB and 100MB
fd --owner username
Files owned by specific user
fd --max-results 100
Limit output to 100 results
fd -x rm {}
Execute command on each result (delete files)
fd -X convert {} {.}.png
Execute command with multiple args (batch convert)
fd --color never pattern
Disable colored output
fd --strip-cwd-prefix pattern
Remove ./ prefix from results
fd -H -t d "^\."
Find hidden directories (starting with dot)
fd -t f -x du -h {}
Show file sizes for all matches
fd pattern --threads 1
Use single thread (for debugging)
fd --base-directory /path pattern
Change base directory for search
Configuration
Configuration Files
Global ignore file locations:
- Linux/macOS: ~/.config/fd/ignore or ~/.fdignore
- Windows: %APPDATA%\fd\ignore
Project-specific: .fdignore in project root
.fdignore File Example
# Ignore dependency directories
node_modules/
vendor/
target/
# Ignore build outputs
build/
dist/
*.o
*.pyc
# Ignore IDE directories
.idea/
.vscode/
*.swp
# Ignore log files
*.log
logs/
# Ignore temporary files
*.tmp
*~
.DS_Store
# Ignore specific paths
/cache/
/tmp/
Environment Variables
# Set default options for all fd commands
export FD_OPTS = "--hidden --follow --exclude .git"
# Control colorization (fd respects LS_COLORS)
export LS_COLORS = "di=34:ln=35:ex=31:*.txt=33"
Useful Aliases
# Add to ~/.bashrc or ~/.zshrc
# Search including hidden files
alias fdh = 'fd -H'
# Search ignoring .gitignore
alias fda = 'fd -I'
# Find large files
alias fdl = 'fd --size +100m'
# Find recent files (last 24 hours)
alias fdr = 'fd --changed-within 1d'
# Find and preview with fzf and bat
alias fdf = 'fd -t f | fzf --preview "bat --color=always {}"'
# Find and edit with vim
alias fdv = 'fd -t f | fzf | xargs -r vim'
Common Use Cases
Use Case 1: Clean Build Artifacts
# Remove all Python compiled files
fd -e pyc -e pyo -x rm {}
# Remove all node_modules directories (up to 2 levels deep)
fd -t d -d 2 '^node_modules$' -x rm -rf {}
# Clean old log files (older than 30 days)
fd -e log --changed-before 30d -x rm {}
# Remove all temporary files
fd -g '*.tmp' -g '*~' -g '*.swp' -x rm {}
Use Case 2: Code Search and Analysis
# Find all JavaScript/TypeScript files modified in last week
fd -e js -e ts -e jsx -e tsx --changed-within 7d
# Count lines of code in Rust project
fd -e rs -x wc -l {} | awk '{sum+=$1} END {print sum}'
# Find all TODO comments in Python files
fd -e py -x grep -Hn "TODO:" {}
# Find largest source files
fd -e java -e kt -x du -h {} | sort -hr | head -20
# Find files containing specific function name
fd -e cpp -e hpp -x grep -l "myFunction" {}
Use Case 3: Log File Management
# Find and compress logs older than 7 days
fd -e log --changed-before 7d -x gzip {}
# Search for errors in recent logs
fd -e log --changed-within 1d -x grep -i "error" {} \;
# Find large log files (over 100MB)
fd -e log --size +100m -l
# Archive old logs to separate directory
fd -e log --changed-before 30d -x mv {} /archive/logs/
Use Case 4: Docker and Container Management
# Find all Dockerfiles in project
fd -g '*Dockerfile*' -g 'Dockerfile.*'
# Find all docker-compose files
fd -g 'docker-compose*.yml' -g 'docker-compose*.yaml'
# Find and validate Dockerfiles
fd '^Dockerfile$' -x docker build --dry-run -f {} .
# Find container-related configs
fd -e yml -e yaml -x grep -l "kind:" {} \;
Use Case 5: Security and Permissions Audit
# Find world-writable files (security risk)
fd -t f -x sh -c 'test -w {} && ls -l {}'
# Find SUID/SGID binaries
fd -t x -x sh -c 'test -u {} -o -g {} && ls -l {}'
# Find files with passwords in name
fd -i password -i passwd -i secret
# Find configuration files with potential secrets
fd -g '*.conf' -g '*.cfg' -g '*.ini' -x grep -i "password\|secret\|key" {}
# Find SSH keys
fd -g 'id_rsa*' -g 'id_ed25519*' -H
Best Practices
Use .fdignore files : Create project-specific ignore patterns to speed up searches and reduce noise
Leverage smart defaults : fd automatically respects .gitignore - use -I only when you need ignored files
Combine with other tools : Pipe fd output to xargs, grep, or fzf for powerful workflows
Use -0 with xargs : Always use fd -0 | xargs -0 for filenames with spaces or special characters
Prefer -x over pipes : Use fd -x command {} instead of piping to xargs for better performance
Set depth limits : Use -d flag on large directory trees to prevent excessive recursion
Use specific type filters : Filter by type (-t f, -t d) early to reduce search space
Create aliases : Set up shell aliases for frequently used fd patterns to save typing
Combine time and size filters : Use --changed-within and --size together for precise file targeting
Test regex patterns : Use online regex testers before complex fd searches to verify patterns
Troubleshooting
Issue
Solution
Command not found: fd
On Debian/Ubuntu, binary is fdfind. Create symlink: ln -s $(which fdfind) ~/.local/bin/fd
Too many results
Use depth limit -d 3, exclude patterns -E node_modules, or filter by type -t f
Not finding hidden files
Add -H flag to include hidden files, or -HI to also ignore .gitignore rules
Search is too slow
Reduce depth with -d, exclude large directories with -E, or use --threads to control parallelism
Regex not matching
Remember fd uses case-insensitive search by default. Use -s for case-sensitive or -F for literal strings
Files in .gitignore showing up
This shouldn't happen by default. Check for -I or --no-ignore flags in aliases or FD_OPTS
Special characters in filenames breaking commands
Use -0 with xargs -0 or use -x flag instead: fd pattern -x command {}
Cannot execute command on results
Check if using correct syntax: -x for individual execution, -X for batch execution
Color output in logs/files
Disable with --color never or redirect stderr: fd pattern 2>/dev/null
Permission denied errors
Redirect stderr to ignore: fd pattern 2>/dev/null or run with appropriate permissions
Not respecting .fdignore file
Ensure .fdignore is in project root or ~/.config/fd/ignore. Check file syntax matches .gitignore format
Results missing expected files
Check if files match your filters (extension, type, size, time). Try with -HI to see all files