find walks a directory tree and lists what matches. Learn -name to filter by name, -type to separate files from directories and -maxdepth to stop it going deeper, by running the commands in a real terminal in your browser.
Updated: 2026-09-05
find starting-point [conditions]
Walks everything below the starting point and lists what matches. With no conditions, you get all of it.
The terminal on this page has a directory tree with a bit of depth to it.
$ find .
.
./src
./src/components
./src/components/Button.js
./src/index.js
./src/utils.js
./docs
./docs/guide.md
./logs
./logs/app.log
./README.md
./package.json
The . is the directory you are in.
Unlike ls, this went all the way down.
Pass the name you want to -name, and quote anything with a * in it.
$ find . -name "*.js"
./src/components/Button.js
./src/index.js
./src/utils.js
Depth does not matter, only the name.
$ find . -name "*.md"
./docs/guide.md
./README.md
-type d gives you directories only, -type f files only.
$ find . -type d
.
./src
./src/components
./docs
./logs
The starting point does not have to be ..
$ find src -type f
src/components/Button.js
src/index.js
src/utils.js
-maxdepth stops it from going further down.
$ find . -maxdepth 1
.
./src
./docs
./logs
./README.md
./package.json
Conditions combine.
$ find . -name "*.js" -maxdepth 2
./src/index.js
./src/utils.js
find is what you type when you do not remember where you put it.
| Situation | What you type |
|---|---|
| The config file is somewhere in here | find . -name "*.config.js" |
| Get a feel for the directory layout | find . -type d -maxdepth 2 |
| Look inside everything you found | find . -name "*.log" -exec cat {} \; |
| Match regardless of case | find . -iname "readme*" |
Always quote the *.
find . -name *.js lets the shell expand the pattern first, which is not what you meant.
find . -name "*.js" hands it to find intact.
Leaving out the starting point searches everything.
On a real machine find / -name ... walks the entire system and takes a long time.
Start narrow with . or src, then widen.
It looks for the files themselves.
When you care about what is written inside them, that is grep.
webterm.appthis site
Terminal Fundamentals
Learn commonly used commands
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course