Linux Command Basics — Day 3: Read, Route, and Reveal

Objectives

  • Inspect file contents with cat/less/head/tail
  • Redirect output using > and >>
  • Combine commands with pipes and filter with grep
  • Read permission bits with ls -l and change them with chmod

Materials

  • Computers with terminal access

Activities

Mission: Read, Route, and Reveal

Your Goal

Using the workspace you created on Day 2 (mission-day2), discover how to inspect file contents, combine commands, redirect output, search inside files, and make a quick permission change. Learn by doing — run small experiments, record command + output evidence, and explain what you discovered.

Allowed Tools (today)

cat
less
head
tail 
echo 
> 
>> 
| grep 
ls -l
chmod
pwd
ls
cd (from earlier days)

Rules

  • Work in pairs; switch Driver/Navigator every 8 minutes.
  • Record each task with: command used, exact output (or screenshot), and 1–2 sentence explanation.
  • Work inside your ~/mission-day2/ workspace. If it doesn’t exist, recreate a minimal version.
  • Use hint ladder only when stuck.

Starter checks (do these first)

1. cd ~/mission-day2

2. ls -la

3. pwd

Record outputs for your notebook.

Tasks — Inquiry Challenges

Each task is short. Try without hints; use hint ladder if needed.

Task A — Read the evidence

  • Find notes/idea1.txt (or any .txt you created). Use at least two different commands to view its contents (try cat, less, head, tail).
  • Evidence: the commands you ran and short notes on when each tool is useful.

Task B — Create proof with redirection

  • Use echo with > to create notes/proof.txt containing a one-line statement (your name + timestamp). Then append one more line with >>.
  • Evidence: command lines and cat notes/proof.txt output.

Task C — Combine and filter

  • Pipe text through commands: list files in notes/ and drafts/ and show only .txt lines using ls -l | grep ".txt" (or other pipeline that works on your system).
  • Search inside files: find lines containing the word idea with grep -n "idea" notes/*.
  • Evidence: the pipeline commands and outputs, briefly explain what each part did.

Task D — Head/Tail detective

  • For any file with 10+ lines (create one if needed by appending), use head -n 5 and tail -n 5 to show different parts.
  • Evidence: commands and outputs; note when head/tail help you.

Task E — Quick permissions intro

  • Use ls -l on a file (e.g., drafts/final_draft.txt) to read permission bits.
  • Make a copy chmod_copy.txt of a file (cp), then use chmod u+x chmod_copy.txt to give yourself execute permission. Explain what changed in ls -l.
  • Optional challenge: try chmod g-w or chmod o-r and observe.
  • Evidence: before/after ls -l outputs and the chmod commands you ran.

Exit Ticket (short answers)

1. Which command shows file contents without editing? Give one example.

2. What does > do vs >>?

3. How does a pipe (|) help combine commands?

4. What does ls -l show that plain ls does not?

Assessment (performance)

Students must submit a single text file mission-day3-evidence.txt in ~/mission-day2/ containing:

  • For Tasks A–E: each task header, the commands you ran, the captured outputs (or pasted snippets), and a one-line conclusion.
  • Minimum: 5 command+output pairs that show use of cat/less, echo with >, a pipeline with grep, head or tail, and ls -l + chmod.

Student Handout (printable)

Cheat-sheet (quick commands)

  • View: cat file.txt
  • Paginate: less file.txt (q to quit)
  • First/last lines: head -n 10 file.txt | tail -n 10 file.txt
  • Write a line: echo "text" > file.txt (overwrite)
  • Append a line: echo "more" >> file.txt
  • Pipe output: ls -l | grep ".txt"
  • Search inside files: grep -n "pattern" files*
  • List long: ls -l (permissions, owner, size, date)
  • Change perms: chmod u+x file.sh (add execute for owner)

Tasks (short)

  • A: Use two viewers on notes/idea1.txt and explain differences.
  • B: Create notes/proof.txt with echo, append a line, show content.
  • C: Use a pipeline to list only .txt files and search inside them with grep.
  • D: Use head/tail on a 10+ line file.
  • E: Show ls -l, change a permission with chmod, show ls -l again.

Submission: save mission-day3-evidence.txt in ~/mission-day2/ with your evidence.

Hint Ladder

Hint 1 — gentle

  • cat shows whole file. less lets you scroll. head/tail show ends of files.
  • > replaces file; >> adds to it.
  • | sends output of left command to the right command.

Hint 2 — specific

  • Try: echo "My name $(date)" > notes/proof.txt
  • To search: grep -n "idea" notes/*
  • To show permissions: ls -l notes/proof.txt

Hint 3 — explicit commands

  • cat notes/idea1.txt
  • less notes/idea1.txt
  • head -n 5 notes/idea1.txt
  • echo "line" >> notes/proof.txt
  • ls -l | grep ".txt"
  • chmod u+x notes/proof.txt

Differentiation

  • Struggling students: focus on Tasks A and B only (viewing + redirection). Ask them to submit 3 command+output pairs.
  • Advanced students: chain multiple greps, use grep -r to search recursively, or create a small script file and run chmod +x then ./script.

Final check

Ensure ~/mission-day2/mission-day3-evidence.txt exists and contains all required evidence.

Exit Ticket

1) Which command shows file contents without editing?

2) What does > do vs >>?

3) How does a pipe (|) help combine commands?

4) What does ls -l show that plain ls does not?

Similar Posts