Suggested day 2020–30 minutesSafe in practice folder Module milestone

Mission 5 of 5

Archiving and Compression

Create, inspect, extract, and verify a recoverable archive.

Bundle, compress, inspect, and extract files in your sandbox.

Outcome: You can make and restore backups of folders confidently.

Mental model

Understand what is happening

tar bundles files; gzip compresses data.

List archive contents before extracting unknown archives.

Extract into a folder to avoid clutter.

Guided lab

Work through the mission

1

Create archive lab

Safe

Creates a folder to archive.

Terminal
cd ~/linux-practice
mkdir -p archive-lab/docs
echo 'file1' > archive-lab/file1.txt
echo 'readme' > archive-lab/docs/README.txt
2

Tar and inspect

Safe

Creates a compressed tar archive and lists its contents.

Terminal
mkdir -p backups
tar -czvf backups/archive-lab.tgz archive-lab
tar -tvf backups/archive-lab.tgz
3

Extract safely

Safe

Extracts into a dedicated restored folder.

Terminal
mkdir -p restored
tar -xzvf backups/archive-lab.tgz -C restored
ls -R restored

Checkpoint

Verify the mission

The archive lists correctly and restores into a dedicated directory.

Try it yourself

One step without a recipe

Use history and predictable glob expansion to collect selected files, link one into a project, archive the project outside it, and verify the archive can be listed.

Need a hint?

Always test your tar command with `t` (list) before extracting. It's like reading the label before opening a mystery box.

Explain it back

Before you move on

  • Which tar option lists contents?
  • Why use -C when extracting?

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