Every Linux power-user eventually discovers that searching is half the battle. Whether you’re debugging a sprawling codebase, locating logs on a remote server, or tracking down configuration files in dozens of directories, recursive file search becomes a critical everyday skill. Thankfully, Linux provides a powerful set of tools that let you find anything—by name, content, size, or time—with just a few keystrokes. This guide covers ten essential commands to help you search like a pro. You’ll learn how they work, when to use them, and how to combine them for maximum power.
1. find — the Swiss‑Army Knife of Search
The find command is incredibly flexible. It can search for files by name, type, size, time modified, ownership, and permissions—all recursively. It’s available by default on all Linux systems.
$ find /home/myuser/code -type f -name "*.py" -mtime -1 /home/myuser/code/app.py /home/myuser/code/scripts/install.py
This example finds all Python files modified in the last 24 hours. You can also combine it with -exec to perform actions on the results.
2. grep -R — Classic Content Search
grep is the go-to tool for searching inside files. Use the -R option to enable recursive search through directories. It’s simple, fast, and powerful.
$ grep -R "database_url" /home/myuser/projects /home/myuser/projects/app/config.py:database_url = "postgres://localhost"
Add -n to include line numbers, -i for case-insensitive search, and --exclude-dir to skip directories like .git.
3. find … -exec grep — Combine for Precision
Combine find and grep for powerful filtered content searches. You can use find to restrict by filename or path and then search content using grep.
$ find /home/myuser/code -type f -name "*.js" -exec grep -Hn "fetch(" {} +
/home/myuser/code/api.js:12:fetch("/api/data");
/home/myuser/code/utils/network.js:45:fetch(url, options);
This command searches only JavaScript files for the word “fetch”.
4. ripgrep (rg) — The Fastest Text Searcher
ripgrep (or rg) is a modern alternative to grep, written in Rust. It’s extremely fast, respects your .gitignore files, and provides smart defaults for developers.
$ rg "TODO" /home/myuser/code /home/myuser/code/main.py:12:# TODO: Refactor this block /home/myuser/code/utils.py:7:# TODO: Add error handling
rg is ideal for large projects. It’s recursive by default and much faster than traditional grep in most use cases.
5. ag — The Silver Searcher
ag (The Silver Searcher) is another fast, recursive search tool, similar to rg. It’s slightly older but still very useful and commonly found on developer systems.
$ ag "authToken" /home/myuser/webapp
webapp/app.js:45:const token = localStorage.getItem("authToken");
ag also ignores files listed in .gitignore by default and supports language-specific filtering using --js, --python, etc.
6. ack — Language-Smart Search
ack is a Perl-based search tool that recognizes file types and extensions automatically. It’s perfect for searching inside codebases without needing a lot of options.
$ ack "class User" /home/myuser/code src/models/user.py 1:class User:
ack is intuitive for developers and works well in cross-language projects.
7. fd — Modern and User-Friendly Find
fd is a simpler, faster, and more user-friendly alternative to find. It supports colorized output, smart defaults, and regular expressions.
$ fd -e conf -H nginx /etc /etc/nginx/nginx.conf /etc/nginx/sites-available/default.conf
fd ignores hidden files by default but supports easy overrides with -H and -I. It’s great for quick and readable results.
8. locate — Instant Filename Lookup
locate uses a database to search for filenames instantly across the entire system. It’s extremely fast but may be slightly out of date unless you run updatedb manually or via cron.
$ locate nginx.conf /etc/nginx/nginx.conf /home/myuser/backup/nginx.conf
This is perfect when you know the file name but not the location.
9. tree -P — Directory Visualization
tree shows a directory structure in a readable hierarchy. With the -P option, you can match filenames using wildcards.
$ tree -P '*.log' -fi /var/log /var/log/syslog.log /var/log/auth.log
Use -L to limit the depth and -d to display only directories.
10. Bash Globstar (**) — Native Recursive Globs
Bash 4+ supports a globstar option that enables recursive wildcard patterns using **. This can be used in any Bash script or interactive shell.
$ shopt -s globstar $ ls **/*.md README.md docs/usage.md
It’s useful for quick recursive listings without external commands like find.
Final Thoughts
Linux provides a rich set of tools to help you search files and directories with incredible flexibility. Whether you’re trying to locate a misplaced configuration file, searching logs for error messages, or reviewing all usage of a variable in a large codebase, there’s a command here to help you do it quickly and efficiently.
To get the best results, learn how to combine these tools. For example, use fd to find files and pipe them into xargs grep for fast content searches. Or use find for complex filtering, then use -exec to process results. Tools like rg, ag, and ack are optimized for developers and will dramatically speed up your daily tasks.
Pro tip: Save time by creating aliases in your .bashrc or .zshrc file, such as alias ff='fd --hidden' or alias rgg='rg --ignore-case'. You’ll soon be navigating and querying your filesystem faster than ever before.