Mission 5 of 5
Archiving and Compression
Create, inspect, extract, and verify a recoverable archive.
Bundle, compress, inspect, and extract files in your sandbox.
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
Create archive lab
Creates a folder to archive.
cd ~/linux-practice
mkdir -p archive-lab/docs
echo 'file1' > archive-lab/file1.txt
echo 'readme' > archive-lab/docs/README.txtTar and inspect
Creates a compressed tar archive and lists its contents.
mkdir -p backups
tar -czvf backups/archive-lab.tgz archive-lab
tar -tvf backups/archive-lab.tgzExtract safely
Extracts into a dedicated restored folder.
mkdir -p restored
tar -xzvf backups/archive-lab.tgz -C restored
ls -R restoredCheckpoint
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?