Thuta Learning
BasicDevOps & Toolsbeginner

Finding Anything with find, locate, and which

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Get comfortable with find, locate, and which — no need to fear them
  • Practice running the commands yourself in the terminal
  • See how these commands come in handy on a real server or project

Let's think about it this way for a second

find /path -name "pattern" searches the whole folder tree and shows every file/folder matching the name pattern — it's a real-time search, so it can be a bit slow on big folders, but it's accurate. locate is faster because it searches a pre-built database the system already has, but if you just created a file, you won't see it until the database gets updated (updatedb). which works differently — it shows you which folder a program file is being run from for a given command (e.g. which python3).

Let's connect this to a real-world scenario

If you want to find where report.pdf is in your Downloads folder, type find ~/Downloads -name "report.pdf". To find every .txt file in a whole folder, use find . -name "*.txt" (you can use the wildcard *) — you've already seen in an earlier chapter that . is shorthand for 'here'. To find out where Python is running from, try which python3 — the output will return a path like /usr/bin/python3.

Let's try it together in the terminal

bash
find ~/Downloads -name "report.pdf"
find . -name "*.txt"
locate hostname
which python3
You should see
Matching files show up as full paths (e.g. /home/user/Downloads/report.pdf).

5-Minute Try-It

Create two .txt files in your practice folder, then search for them with find . -name "*.txt".

A Quick Word of Caution

If you use * in a find pattern, wrap it in quotes ("") — otherwise the shell may expand the * itself, and you'll get unexpected results.

Easy traps

  • Running find on huge folders (like root /) and not knowing you can hit Ctrl+C when it's taking forever
  • Trusting stale locate results because the database hasn't been updated yet

Now Try It Yourself

Create two .txt files in your practice folder, then search for them with find . -name "*.txt".

You'll know it worked when: Matching files show up as full paths (e.g. /home/user/Downloads/report.pdf).

Finding Anything with find, locate, and which | Thuta Learning