0:00–0:10
Recap
0:10–0:30
Lecture
0:30–1:45
Lab 2 Pt 3–5
1:45–1:55
Bonus
1:55–2:00
Wrap
0:00 – 0:10 Recap · 10 min

Path challenge and command warm-up

0:10 – 0:30 Lecture · 20 min

find, grep, sudo — three tools that make the CLI genuinely powerful

sudo — borrowing superuser privilege (5 min)

find — locate files anywhere on the system (8 min)

FlagWhat it matchesExample
-name "pattern"Filename — case sensitive. Use -iname for case-insensitivefind / -name "beh"
-size +500MFiles larger than 500 MB. Use - for smaller than, no sign for exactfind / -size +500M
-mmin -10Modified in the last 10 minutes. -mtime for daysfind / -name "*.log" -mmin -10
-type fFiles only. -type d for directoriesfind /etc -type f -name "*.conf"
2>/dev/nullNot a find flag — redirect errors to nowhere. Suppresses "Permission denied" noisefind / -name "beh" 2>/dev/null

grep — search inside files (7 min)

FlagEffectExample
-iCase-insensitive matchgrep -i "student" /etc/passwd
-rRecursive — search all files in a directory treegrep -r "root" /etc/
-nShow line numbersgrep -n "bash" /etc/shells
-cCount matching lines instead of printing themgrep -c "bash" /etc/shells
-vInvert — show lines that do NOT matchgrep -v "nologin" /etc/passwd
* wildcardSearch multiple files matching a patterngrep "root" /etc/pass*
grep + pipe = power: grep becomes transformative when used in a pipeline. cat /etc/passwd | grep "student" is equivalent to grep "student" /etc/passwd — but the pipe approach lets you chain further. cat ~/.bash_history | grep "find" | wc -l counts how many times you've run the find command. You'll use this exact pattern in today's lab.
0:30 – 1:45 Lab 2 Parts 3–5 · 75 min

Lab 2 — Searching, text files, file operations, and disk usage

Parts 3, 4, and 5 of Lab 2, building on the directories created yesterday. The lab work today produces several files that will persist on the VM — don't delete them, they may be referenced in later labs.

Part 3 — Searching the filesystem with find and grep (25 min)

Instructor note — the /etc/passwd grep is a teaching moment: The fields in /etc/passwd are colon-separated: username:password placeholder:UID:GID:comment:home directory:shell. Walk through the student entry with the class. The "x" in the password field means the actual hash is in /etc/shadow, which is only readable by root. Ask: why keep the password hash in a separate file?

Part 4 — Creating and manipulating text files (30 min)

Part 5 — Disk usage tools (20 min)

1:45 – 1:55 Bonus · 10 min

Piping, wc, and the man page habit

1:55 – 2:00 Wrap · 5 min

Tomorrow is the first mini-assessment — what to expect

Learning outcomes — by end of Day 4, students can…

Use sudo appropriatelyExplain what sudo does, why it's preferable to logging in as root, and when it's required
Search with findLocate files by name, size, and modification time — suppress permission errors cleanly
Search with grepFind matching lines in files, count them, search multiple files, and pipe output through grep
Create and read text filesUse echo redirection to create files, and cat/less to read them
Copy and move filesUse cp and mv correctly, including renaming files by changing the target path
Check disk usageUse df -Th and du with depth and human-readable flags to report filesystem usage

What to have ready before class

Lab 2 Parts 3–5 handout printed Mini-Assessment 1 printed and ready for Friday Remind students to complete Lab 2 if not finished in class
←← Week 1 Overview ← Day 3 Lab 1D Handout Day 5 →