Suggested day 1120–30 minutesCaution

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.

Outcome: You can locate files without guessing where they are.

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

1

Create search lab

Safe

Creates harmless test files.

Terminal
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.txt
2

Find files

Safe

Searches by name and type.

Terminal
find find-lab -name '*.txt'
find find-lab -type f
find find-lab -type d
find find-lab -empty
3

Act on results

Safe

Lists matching files and prints logs before any deletion.

Terminal
find find-lab -name '*.txt' -exec ls -lh {} \;
find find-lab -name '*.log' -print
4

Delete only after printing

Caution

Deletes only the practice .log file after you have confirmed the match.

Terminal
find find-lab -name '*.log' -delete

Checkpoint

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?

Shortcuts:Alt + ← previous lessonAlt + → next lessonAlt + H home? focus search