To find files in Linux with a certain name portion or pattern we can issue a locate command. If locate is unable to find a matching file, then you might need to update your file index database.
1 2 | # locate journal-2011-07 # updatedb |
In the example above we are trying to find a file that has journal-2011-07 in its name which can be journal-2011-07-01, journal-2011-07-02, my-journal-2011-07-09, etc.
You can also use the find command. The find command does not use a file indexing algorithm which might be slower than locate. The example below will look for all files with the xml extension inside /home/ronald. The find command by default is recursive — it will look into subfolders.
1 | find /home/ronald/ -name *.xml |
2026 update — a few useful additions. 🔍
Always quote the pattern. The example above works, but it has a subtle gotcha: *.xml is unquoted, so your shell tries to expand it against files in your current directory before find ever sees it. If there happens to be one matching file in the current directory, find ends up looking for that exact filename instead of the pattern. Quote it to be safe:
1 | find /home/ronald/ -name "*.xml" |
Case-insensitive search with -iname — handy when you don’t know if the file is Report.PDF or report.pdf:
1 | find /home/ronald/ -iname "*.pdf" |
Find by size — for example, all files larger than 100 MB:
1 | find /home/ronald/ -type f -size +100M |
Find recently modified files — anything touched in the last 24 hours:
1 | find /home/ronald/ -type f -mtime -1 |
Use -mtime +7 for files older than 7 days — -n means “less than n days”, +n means “more than n days”.
What about locate in 2026? The classic locate / updatedb from 2011 has largely been replaced by mlocate or, on newer distros, plocate. The commands work the same way — locate journal-2011-07 still does what you’d expect — but on a fresh install you may need to install the package first (e.g. sudo apt install plocate). The index is usually refreshed nightly by a cron/systemd job, so manual updatedb calls are rarely needed anymore.
A friendlier alternative: fd. If you find find‘s syntax fiddly, fd is a modern replacement with sensible defaults (recursive, smart-case, respects .gitignore). The same XML search becomes:
1 | fd -e xml . /home/ronald |
Pick whichever fits your 🧠 brain muscle memory — find is universally available, fd is nicer to type. 💡