Beginner · 40 minutes · Practical project

Project: organise and archive a workspace

Combine navigation, text filtering and permissions into a verified handover.

By the end of this lesson

  • Deliver a tidy set of source and derived files
  • Create and inspect a small archive
  • Restore to a separate directory and compare the contents

Your environment: Bash and the named tools in a Linux lab. Minimal distributions may require extra packages. Setup help

Plan your deliverable

Your first project is a handover folder for a colleague. The source file contains mixed event types, while the handover needs a short error report and a note explaining how it was produced. Success means another person can understand your work and reproduce the report; merely running the commands is not enough.

Separate source data from derived reports. If you cannot explain where a report came from, you cannot confidently rebuild it. Use relative paths within the archive so extraction does not depend on your original home-directory name.

Verify the result rather than its existence

An archive file existing is only the start of a check. List its members, restore into a separate empty directory, and compare the restored source with the original. This catches wrong-path and omitted-file mistakes. Never test a restore over the only good copy.

This is a local training exercise, not a production backup strategy. A real backup also needs an independent failure domain, retention, access controls and rehearsed recovery. Here the learning outcome is a repeatable create–inspect–restore–compare sequence. Write a short explanation alongside the files.

See it in context

Worked example

List an archive before extracting it.

# Example syntax; the project solution creates handover.tar.gz first.
# tar -tzf handover.tar.gz

The listing should contain project-relative member names, not unrelated files from your home directory.

Your turn

Practical project

Create a handover with the error events and prove that its archive restores correctly.

Run commands in your own lab. This website displays instructions; the practice terminal below helps you rehearse the syntax.

1. Prepare your workspace

mkdir -p "$HOME/training4linux/foundation-project/source" "$HOME/training4linux/foundation-project/report" "$HOME/training4linux/foundation-project/restored"
cd "$HOME/training4linux/foundation-project"
printf "%s\n" "INFO start" "ERROR disk" "INFO ready" "ERROR timeout" > source/events.log

2. Complete the task

  1. Build report/errors.txt with only the ERROR records and add report/README.txt describing the filter.
  2. Make report/errors.txt readable and writable only by you.
  3. Archive source and report into handover.tar.gz, list the members, then extract into restored.
  4. Compare the restored source with the original and record the error count.

3. Check your result

  • The report contains 2 lines.
  • The archive includes both source and report, plus the explanation file.
  • diff produces no differences for the original and restored events.log.
Need a hint?

Run tar from the project directory. Use -C restored for the extraction destination.

Reveal a worked solution

Compare this with your approach after trying the task. More than one valid solution may exist.

grep "^ERROR" source/events.log > report/errors.txt
printf "%s\n" "Filter: lines beginning with ERROR from source/events.log" > report/README.txt
chmod 600 report/errors.txt
tar -czf handover.tar.gz source report
tar -tzf handover.tar.gz
tar -xzf handover.tar.gz -C restored
diff source/events.log restored/source/events.log
wc -l report/errors.txt

After the lab: Keep the archive and handover as your first project. Re-extracting may overwrite the earlier restored practice copies.

Common mistakes to avoid

  • A local archive on the same disk is not sufficient disaster-recovery protection.

Check your understanding

Knowledge check

Answer all 3 questions correctly to pass. Retry as often as you need; your best score is kept.

1. Which step gives stronger restore evidence than file existence?
2. Where should the test restore go?
3. How many ERROR lines are in the supplied source?

Your lesson progress

Not started · Best score: 0% · Attempts: 0

Practical completion is self-reported. Progress is linked to a private cookie in this browser and stored on the site. Clearing that cookie loses access to it. Manage or erase progress.

Keep the reference close

Further reading