Mission 1 of 5
Find Command Mastery
Locate a missing file and prove the match before acting on it.
Locate files by name, type, size, time, permissions, and then act carefully on the results.
Mental model
Understand what is happening
find starts at a folder and walks downward.
Print results first before deleting.
-exec runs another command on each match.
Guided lab
Work through the mission
Create search lab
Creates harmless test files.
cd ~/linux-practice
mkdir -p find-lab/subdir/nested
touch find-lab/file1.txt find-lab/file2.pdf find-lab/old.log find-lab/subdir/test.txtFind files
Searches by name and type.
find find-lab -name '*.txt'
find find-lab -type f
find find-lab -type d
find find-lab -emptyAct on results
Lists matching files and prints logs before any deletion.
find find-lab -name '*.txt' -exec ls -lh {} \;
find find-lab -name '*.log' -printDelete only after printing
Deletes only the practice .log file after you have confirmed the match.
find find-lab -name '*.log' -deleteCheckpoint
Verify the mission
Every match is printed before any action is taken.
Try it yourself
One step without a recipe
Find all .txt files inside find-lab. Use -exec wc -l on matching files.
Need a hint?
Always print your results before deleting anything. Run `find . -name '*.log' -print` and read the list. If it looks right, swap `-print` for `-delete`. This two-step habit has saved me from wiping files I needed more times than I care to count.
Explain it back
Before you move on
- Which option searches by file type?
- What should you do before -delete?