
How to Find Files in Linux
Finding files in Linux is a rite of passage — but it doesn’t have to be a pain. Whether you’re deep in a messy project folder or just forgot where you saved that config, this guide covers all the ways to find things fast.
We’ll start simple, then branch out to powerful tools for developers, sysadmins, and everyday terminal users.
1. The Classic: find
The find
command is the Swiss army knife of file searching. It’s built-in, recursive by default, and works everywhere.
Find a file by name (current directory):
find . -name "file.txt"
.
means: start in the current directory-name
is case-sensitive- Use
-iname
for case-insensitive
Search from home:
find ~ -name "*.jpg"
Search everything (root):
sudo find / -name "config.yaml"
Tip: Use quotes when searching patterns ("*.sh"
), or the shell may expand them before find
gets a chance.
2. The Fast One: locate
+ updatedb
locate
searches a pre-built index of all files — insanely fast, but not always current.
locate notes.md
If it’s missing something you just created, run:
sudo updatedb
Then search again. Great for frequently-used files.
3. The Cleanest Combo: ls | grep
Your favorite — and for good reason.
From current directory:
ls | grep html
From home:
ls ~ | grep pdf
Recursively in subfolders:
find . -type f | grep .html
Or for a cleaner recursive match:
find . -name "*.html"
4. By Size, Date, or Extension
Files over 50MB:
find . -size +50M
Modified in the last 2 days:
find . -mtime -2
All .log
files anywhere:
find / -name "*.log" 2>/dev/null
(The 2>/dev/null
silences permission errors.)
5. Fancy & Fast: fd
(a modern find)
If you’ve installed fd
:
fd config ~/.config
This tool supports smart case matching, parallel search, and cleaner output by default.
Summary Cheat Sheet
Goal | Command Example |
---|---|
Current dir search | find . -name "*.txt" |
Home dir search | find ~ -iname "*.md" |
Root search | sudo find / -name "something.txt" |
Instant search | locate file.txt |
Filter with grep | ls | grep pattern |
Search subfolders | find . -type f | grep something |
Size > 100MB | find . -size +100M |
Recently modified | find . -mtime -1 |
Use the command line like you own it. This guide stays useful even when your file names don’t.
Last updated: 2025-04-09 04:58 UTC