Linux command list

find command: locate files by name or type

__ __ _ _____
\ \ / /__| |_|_ _|__ _ __ _ __ ___
\ \ /\ / / _ \ '_ \| |/ _ \ '__| '_ ` _ \
\ V V / __/ |_) | | __/ | | | | | |
\_/\_/ \___|_.__/|_|\___|_| |_| |_| |_
 
A sandbox for trying find. Nothing here can touch your real files.
user@webterm:~/project$
 

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

Syntax

find starting-point [conditions]

Walks everything below the starting point and lists what matches. With no conditions, you get all of it.

Try it first

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.

Filtering by name

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

Filtering by type

-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

Limiting the depth

-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

When you actually reach for it

find is what you type when you do not remember where you put it.

SituationWhat you type
The config file is somewhere in herefind . -name "*.config.js"
Get a feel for the directory layoutfind . -type d -maxdepth 2
Look inside everything you foundfind . -name "*.log" -exec cat {} \;
Match regardless of casefind . -iname "readme*"

Things that trip people up

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.

Practise it hands-on

webterm.appthis site

learn.webterm.appa separate site

>_WEBTERM LEARN

WebTerm Learn: from one command to actually using it

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

Related commands

grep / ls / tree

Frequently asked questions

What is the difference between find and ls?
ls lists one directory, one level deep. find walks everything below the place you point it at, which is how you locate a file you cannot see.
When should I use find and when grep?
find locates files by name or type, grep looks for lines inside them. Where is it, or what does it say.
Why does the -name value need quotes?
Without them the shell expands * before find ever sees it. Quoting as '*.js' passes the pattern through untouched.
What is the dot at the start?
It is where the search begins. A dot means the directory you are in; write src and only that subtree is searched.
Can I ignore capitalisation?
Use -iname instead of -name when you want README.md and readme.md to match the same pattern.