Signal9Signal9 — home
online
back to labs

find vs grep: the #1 Beginner Confusion

EasyLinux Fundamentals10-15 min
The brief

Two tools, two completely different jobs — and mixing them up is the single most common beginner mistake.

• find searches the FILESYSTEM for files, by their name/type/size/owner. It does NOT look inside them.

• grep searches INSIDE files for a line of text. It does NOT hunt for filenames.

You've got a small server estate at /root/estate (config files scattered in subfolders) and a log at /root/logs/system.log. Three tasks — each trivial with the right tool, miserable with the wrong one. Write each answer into the matching file under /root/answers/ (already created for you).

1. find job — list every *.conf file anywhere under /root/estate (full paths) → /root/answers/configs.txt

2. grep job — pull every line containing CRITICAL out of /root/logs/system.log → /root/answers/critical.txt

3. the combo — grep can also report WHICH file matched (grep -l): find the one config that sets 'debug = true' → its full path → /root/answers/debugconf.txt

Do #1 with grep and you'll fight it forever; do #2 with find and you simply can't. That's the lesson.

What you'll do
  • Use find to collect every .conf file path under /root/estate into /root/answers/configs.txt
  • Use grep to extract the CRITICAL lines from the log into /root/answers/critical.txt
  • Use grep -l to name the config file that sets 'debug = true' into /root/answers/debugconf.txt

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.