A Linux system holds hundreds of thousands of files, so “where did I put that?” is a daily question. Luckily, two classic tools answer it: find locates files themselves, and grep searches inside their contents. Together, Linux find and grep are the search team you will use more than almost any other commands. This beginner-friendly guide shows how Linux find and grep work, with small examples you can try on your own files.
Linux Find and Grep Basics: Finding Files with find – How to Search in Linux
The find command walks through folders for you, testing every file against rules you give it. The pattern is: where to look, then what to look for. The most common search is by name:
$ find ~ -name "photo.jpg" # exact name, in your home folder
$ find . -iname "*report*" # part of a name, any capitalisation
Two details matter here. First, the starting point: ~ is your home folder, . means “this folder,” and / searches the entire system (slow, and full of “Permission denied” noise at first – that is normal). Second, the pattern: -name is case-sensitive while -iname is not, and the star * means “any characters.” Keep the pattern in quotes so the shell does not interfere.
Names are only the beginning. You can search by type, size, and age just as easily:
$ find . -type d -name "backup*" # folders only
$ find /var/log -type f -size +100M # files bigger than 100 MB
$ find ~ -mtime -7 # changed in the last 7 days
That last style of search is a lifesaver when a disk fills up – combine it with the ideas in our guide to fixing a full Linux disk.
Linux Find and Grep Basics: Searching Inside Files with grep – How to Search in Linux
While find looks at names, grep reads the contents. Give it a word and a file, and it prints every line containing that word:
$ grep "error" app.log
$ grep -i "error" app.log # -i ignores capital letters
$ grep -n "error" app.log # -n shows the line numbers
$ grep -r "TODO" ~/projects # -r searches a whole folder tree
The recursive search, grep -r, is the one beginners fall in love with: point it at a folder of notes or code and it finds the one line you half-remember writing. Add --color=auto and the matches light up in colour, which your distribution may already do for you.

The real power appears when you connect tools with a pipe, the | symbol, which feeds one command’s output into another. Here, grep filters the output of another command, keeping only the lines about SSH:
$ ps aux | grep ssh
That filtering trick works on almost any command’s output, and tools like Shell-GPT can even help you build these pipelines when you describe what you are hunting for.
Two Power Combinations Worth Practising
Once the basics feel easy, Linux find and grep reward you for combining them. First, let find feed files directly into a search with its -exec option – this hunts for the word “invoice” inside every text file under your Documents folder:
$ find ~/Documents -name "*.txt" -exec grep -l "invoice" {} +
The -l flag asks grep for just the file names, and {} + means “all the files find collected.” Second, counting is searching too: grep -c "error" app.log reports how many lines match instead of printing them, and adding --include="*.log" to a recursive grep limits it to one file type. These little combinations are how experienced users answer questions like “which config file mentions this setting?” in seconds. Practise them on your own notes folder, where a wrong guess costs nothing, and the patterns will be there when a real problem needs them.
Common Beginner Mistakes with find and grep
- Searching the whole system for a home file. Start in
~or.; a full-diskfind /is slow and noisy. - Forgetting quotes around patterns. Without quotes, the shell may expand
*itself and confuse the command. - Expecting
grepto understand questions. It matches literal text (and patterns called regular expressions). If nothing prints, the text simply was not there – try-ifirst. - Being scared by “Permission denied”. During big searches it just means some folders belong to the system. The results you can read still print normally.
Conclusion
Remember the division of labour: Linux find locates files by name, size, or age, and Linux grep finds lines of text inside them – and with a pipe, grep can filter anything. Master these two and no file on your system can hide for long. Give yourself one small mission this week: find the largest file in your home folder using nothing but find and grep. The grep manual page documents every extra flag when you are curious, and our guide to working with text files covers the viewers you will pair with them.