Mission 20 of 30 · Milestone

Archiving and Compression

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

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

45–55 min Week 3 · Productivity, storage, packages, networking Ubuntu terminal
Your outcome: You can make and restore backups of folders confidently.
Practice inside ~/linux-practice. Check your setup before you begin. Prerequisite: Hard Links and Symbolic Links .

What you’ll practice

  • Create tar archives
  • Extract archives
  • Use gzip/zip tools when available

The mental model

  • tar bundles files; gzip compresses data.
  • List archive contents before extracting unknown archives.
  • Extract into a folder to avoid clutter.

Try it in your terminal

Create archive lab

Safe in practice folder

Creates a folder to archive.

Run from ~/linux-practice

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

Tar and inspect

Safe in practice folder

Creates a compressed tar archive and lists its contents.

Run from ~/linux-practice

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

Extract safely

Safe in practice folder

Extracts into a dedicated restored folder.

Run from ~/linux-practice

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

Put it into practice

  1. Archive any three .txt files into backups/my_texts.tgz and list the archive.

Check your result

The archive lists correctly and restores into a dedicated directory.

Milestone challenge

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.

Common mistakes

  • You extract an archive and suddenly have 47 files scattered across your current directory. Always create a target folder first and use `tar -xzvf archive.tgz -C target/`. Your files stay organized, and you know exactly where they went.

Check your understanding

Explain these in your own words. If you’re unsure, revisit the examples before moving on.

  1. Which tar option lists contents?
  2. Why use -C when extracting?

Your practice, your pace

Loading saved progress…

Discussion

Continue the conversation about this guide. Loading comments connects to GitHub Discussions through giscus.

Open community discussions on GitHub

Check before you copy

This command needs care. Read its context, confirm the target and location, and keep a recovery path.

Copying does not run a command.