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.
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 folderCreates 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 folderCreates 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 folderExtracts 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
- 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.
- Which tar option lists contents?
- Why use -C when extracting?
Your practice, your pace
Loading saved progress…