Hi everyone. grep searches inside files, but very often the question is a different one: where is that file, which files are taking up all the space, or what did I change in the last hour? That is the job of the find command. In this guide I run find on Ubuntu 26.04 against the files created in the earlier labs of this series, so every result you see comes from a real home folder.
Along the way you will see the thing that scares most beginners away from find, a screen full of Permission denied messages, and why piping the output into head does not stop it. The guide also covers searching by name, type, size, and time, running a command on each result, and deleting matches safely.
This article follows on from the grep command in Linux. If you need to search for text inside files, that is the one to read.
Distro : Ubuntu 26.04.1 LTS (Desktop)
Start : ~ (home folder) and /
Lab : ~/find-labFinding Files by Name
Search your home folder with -name

find takes a starting folder first, then the conditions.
cd ~
find ~ -name 'notes*'It walks through every folder under home and prints the full path of anything whose name starts with notes. Here it found the notes.txt from the chown lab (number 1). Keep the pattern in single quotes, otherwise the shell may expand the asterisk before find ever sees it.
Ignore case and limit the search to folders

find ~ -iname '*.LOG'
find ~ -maxdepth 1 -type d -name '*-lab'-iname works like -name but ignores case, so ‘*.LOG’ still finds the lower-case log files from the chown lab (number 1), plus a few log files that desktop apps keep in hidden folders. The second command combines three conditions: -maxdepth 1 stays at the top level of home, -type d accepts only directories, and -name filters by name. The result is exactly the three lab folders from this series (number 2). Use -type f when you want only regular files.
The Permission Denied Flood
Search a system folder as a normal user

find /var/cache -name sshd_config | head -n 3I asked for at most three lines with head (number 1), yet six Permission denied messages filled the screen (number 2). Those messages are errors, and Linux sends errors to a separate channel called stderr. The | pipe only passes normal output, so head never sees them. On a search that starts at / this turns into hundreds of lines.
Hide the errors or search as root

find / -name login.defs 2>/dev/null
sudo find / -xdev -type f -size +200M -exec ls -lh {} + 2>/dev/nullAdding 2>/dev/null sends stderr to nowhere, so only real results remain, here the three copies of login.defs on the system (number 1). The second command is one I use whenever a disk fills up. sudo lets find into every folder, -xdev keeps it on the main disk, -size +200M matches files larger than 200 MB, and -exec ls -lh {} + shows each result with a readable size. The biggest file on this machine is the 4.0G swap file (number 2), followed by snap packages.
Note: -size uses k, M, and G for kilobytes, megabytes, and gigabytes. A plus sign means larger than, a minus sign means smaller than, and no sign means exactly that size.
Finding Recently Changed Files
Use -mmin to see what changed in the last hour

find ~ -type f -mmin -60 -not -path '*/.*' | head -n 8-mmin -60 matches files modified less than 60 minutes ago, and -not -path ‘*/.*’ skips anything inside hidden folders, which are full of browser and desktop cache (number 1). The list is a neat record of the last hour of this series, the report, logs, notes, and project files from the permission, chmod, and chown labs (number 2). For days instead of minutes, use -mtime, so -mtime -7 means the last week.
Deleting What You Find
Preview first, then delete with -delete

mkdir -p ~/find-lab && cd ~/find-lab
touch report.txt draft-1.tmp draft-2.tmp cache.tmp
find . -name '*.tmp'
find . -name '*.tmp' -delete
lsAlways run the search on its own first. It lists the three .tmp files and nothing else (number 1). Only then add -delete to the same command (number 2). After that, ls shows that report.txt is the only file left (number 3).
Warning: -delete removes files permanently, without the Trash. Put it at the very end of the command, after all the conditions. If it comes first, find deletes everything it walks past before the name filter is even checked.
My experience: My habit is to type the find command without -delete, read the result, then press the Up arrow and add -delete to that exact line. It costs two seconds and it has saved me from deleting the wrong folder more than once.
Common Problems and How to Fix Them
The screen fills with Permission denied
You are searching folders your user cannot read. Add 2>/dev/null to hide the errors, or run find with sudo if you need results from those folders too.
find returns nothing for a pattern with *
Check that the pattern is in single quotes. Without quotes, the shell may replace ‘*.txt’ with the names of files in the current folder before find runs.
paths must precede expression
This error means find received the conditions in an order it did not expect, often an unquoted pattern that the shell expanded into several names. Quote the pattern and make sure the starting folder comes first.
The search takes very long
Starting at / scans the whole system, including other disks. Start from a narrower folder, add -xdev to stay on one disk, or use -maxdepth to limit how deep it goes.
That covers find in daily use: by name and case, by type, by size, by time, running a command on each result, and deleting carefully. Next in the series is tar, for packing folders like these into one compressed file. If find shows you an error I did not cover, post it in the comments.












