For Linux system administrators managing complex file systems, the find command has long been an indispensable tool for locating files and directories based on various criteria. However, find’s extensive options and sometimes convoluted syntax can slow down routine tasks, especially when speed and simplicity matter. Enter fd: a modern, fast, and intuitive alternative designed to make file searching quicker and more straightforward without sacrificing power. In this tutorial, we will explore what fd does, why it’s becoming the go-to choice for many sysadmins, and practical examples showcasing its use in real Linux environments. By the end, you’ll appreciate how fd streamlines searches and can enhance your daily administrative workflows.
Understanding fd: What It Is and Why It Matters
fd is a modern search tool written in Rust, focused on speed and usability. Unlike find, which tries to cover countless corner cases and offers deeply nested options, fd provides a clean, simple syntax geared towards the most common search use cases. In production settings where you often need to quickly locate files — whether for debugging, configuration reviews, or routine maintenance — fd can save valuable time and reduce cognitive overhead.
What sets fd apart is its emphasis on intelligent defaults: case insensitive by default with case-sensitive fallback when uppercase characters are involved, automatic exclusion of hidden files (unless explicitly requested), respect for .gitignore entries, and Unicode-aware filename handling. These features mean you spend less time crafting complex search expressions and more time focusing on results. Still, fd complements rather than replaces find, since find supports niche and highly customizable criteria required in some scenarios.
In my experience managing Debian-based web servers and RHEL production nodes, I often use fd as a go-to to swiftly locate log files, scripts, or configuration snippets. It’s especially helpful in troubleshooting when you need to quickly narrow down files containing certain keywords or matching specific extensions.
fd -h fd 8.3.2 Search for entries in your filesystem Usage: fd [] [...] Options: -e, --extension Only search files with this extension -E, --exclude Exclude files/directories matching pattern -x, --exec Execute command on each search result -i, --ignore-case Perform case-insensitive search (default) -c, --color Colorize the output (always, never, auto) -h, --help Prints help information
This command shows the basic usage information about fd. Here, -e filters results by file extension, -E excludes specific file patterns, and -x allows executing commands on the results — similar to find -exec. The clean syntax and colorized output by default provide a comfortable user experience that’s easier to read and faster to navigate.
Practical fd Examples for System Administrators
Let’s walk through some realistic use cases where fd shines in day-to-day Linux administration:
fd -e log /var/log /var/log/syslog /var/log/auth.log /var/log/mysql/error.log /var/log/nginx/access.log
Here, we’re searching for all files ending with .log under the /var/log directory. The -e log flag filters files by extension, a common need when tracking down specific log files quickly without digging through unrelated files.
fd error -e conf -E backup /etc /etc/nginx/nginx.conf /etc/mysql/mysql.conf.d/mysqld.cnf /etc/apache2/apache2.conf
This example looks for files with extension .conf that contain the string “error” (case-insensitive by default) excluding any results inside directories named backup. This technique is valuable for auditing configuration files related to error handling without getting distracted by backup directories or ambiguous results.
fd -e sh -x chmod +x {}
./scripts/deploy.sh
./scripts/cleanup.sh
./bin/install.sh
As a typical sysadmin task, we want to ensure all shell scripts have executable permissions. Using -e sh to find shell scripts combined with -x to run chmod +x on each result automates this in a clean and concise way.
One useful trick many administrators overlook is the placeholders {} and its variants. For instance, {/} expands to just the basename, which is handy when constructing commands that should operate only on filenames rather than full paths.
Best Practices When Using fd in Production Systems
Despite its usability, there are several practical tips to get the most out of fd in real-world environments:
- Combine with other tools: Data filtering with
fdis fast, but combining it with tools likexargs,grep, or parallel processing utilities can enhance automation workflows. - Watch exclusions: By default,
fdignores hidden files and respects your.gitignore. If you rely on this behavior, double-check your search paths to avoid unintentionally missing important files. - Leverage colors and regex: The default output includes smart color highlights making it easier to spot relevant files. Also, use regex patterns natively instead of globbing to craft granular search queries.
- Test before bulk operations: When using -x for executing commands on search results, always dry-run your
fdcalls first to avoid disastrous automated changes.
A mistake I often see when managing servers is admins running legacy find scripts blindly without considering newer tools like fd that can simplify command lines and speed up server management.
Troubleshooting Scenario: Diagnosing Configuration Drift with fd
In one troubleshooting case I handled, an application running on CentOS started exhibiting intermittent failures due to incorrect Apache configurations scattered across nested directories. The traditional find commands took minutes and returned overwhelming output. Using fd, I quickly located all .conf files modified in the last 7 days containing the string “LogLevel” excluding backup folders:
fd -e conf -t f --changed-within 7d LogLevel -E backup /etc/httpd /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/custom.conf
This sharp filtering allowed me to pinpoint the config files likely causing the problem and examine them efficiently, saving hours of manual digging. The case demonstrated how fd’s speed and smart filters are crucial when troubleshooting time-sensitive production issues.
Conclusion
fd presents a compelling alternative for Linux administrators who need a fast, clean, and user-friendly tool to search files and directories. While it does not aim to replace the more extensive find command outright, fd fills a niche of daily file searching with smarter defaults, colorful output, and intuitive syntax that can significantly speed up your workflow. In real production environments where time is critical and clarity is paramount, adding fd to your toolkit provides an efficient way to handle file system inspections, bulk file operations, and troubleshooting tasks. If you haven’t yet explored fd, it’s worth installing and trying it out — it might quickly become your preferred search tool.