SI Learning
0% read · Practice is tracked separately
← My learning
Version 1 · Chapter 9Reading mode

Package files and prove you can restore them

By the end: Distinguish compression from archiving and verify a small restore.

The idea

Compression reduces a stream's size; an archive collects files and paths. Keep originals during practice and list an unfamiliar archive before extracting it into a new directory. A backup is useful only when you can restore it and compare the result.

Your command toolkit

gzip

What it solves: Compress a file while preserving its original.

bash
gzip -c notes.txt > notes.txt.gz

-c writes compressed bytes to standard output. Without -c or -k, gzip normally replaces the original with its compressed form.

gunzip

What it solves: Read a gzip stream as plain text.

bash
gunzip -c notes.txt.gz

-c decompresses to the terminal and retains the archive. Redirect to a new path if you want a separate restored file.

zcat

What it solves: Inspect gzip content without an extraction step.

bash
zcat notes.txt.gz

Streams decompressed content. It is convenient for piping a compressed log into grep or head.

bzip2

What it solves: Try another lossless compression format.

bash
bzip2 -c notes.txt > notes.txt.bz2

The .bz2 format differs from gzip. -c retains the source; use bunzip2 or bzip2 -d to decode it.

tar

What it solves: Bundle paths into an archive.

bash
tar -czf notes.tar.gz notes.txt
tar -tzf notes.tar.gz

-c creates, -t lists, -z uses gzip, and -f names the archive. List and review member paths before extraction.

zip

What it solves: Create a widely supported archive.

bash
zip notes.zip notes.txt

zip can package and compress together. A .zip suffix alone does not prove the contents are safe or authentic.

unzip

What it solves: Inspect a ZIP archive before extraction.

bash
unzip -l notes.zip

-l lists entries. Extract into a dedicated empty folder only after checking the archive source and paths.

split

What it solves: Break a stream into manageable chunks.

bash
split -l 2 notes.txt part-

Creates sequential files containing up to two lines each. Keep their order when reassembling; chunking is not encryption.

cpio

What it solves: Understand an archive driven by a file list.

bash
printf '%s\n' notes.txt | cpio -o > notes.cpio

cpio's copy-out mode reads pathnames from input. This example deliberately archives one known practice file.

Before you move on

Try the guided lab below. Compare the result with the explanation, then record your reasoning in the workbook. A missing optional program or a restricted environment is something to explain, not a reason to change system settings blindly.

Practice with evidence

  1. Predict the result
  2. Run the guided lab
  3. Compare the output
  4. Explain your choice

A worked example

Guided lab

bash
si_lab=$(mktemp -d)
cd "$si_lab" || exit
printf 'Plan\nBuild\nVerify\n' > notes.txt
tar -czf notes.tar.gz notes.txt
tar -tzf notes.tar.gz
mkdir restored
tar -xzf notes.tar.gz -C restored
cmp notes.txt restored/notes.txt
printf 'Comparison status: %s\n' "$?"

What to expect: The archive contains notes.txt. The restored file matches byte for byte and the comparison status is 0.

Make it yours: Describe your archive, extraction destination, and comparison result. Explain why listing an archive is different from verifying a restore.

Read further

Apply what you learned

Your private practice

Which result gives evidence that a restored file matches its original?

Answers are private. Completion requires the correct knowledge-check answer and a written response when an activity is included.

Restore a downloaded workbook

Choose a recovery file for this course and version. Review the recovered copy before saving it to your account.

Ask a question or report a problem

Describe what needs attention. Your private answer is shared only if you select the option below.

All learning paths
SI CENTRALIZATION · LEARN

Linux Command Line: from first command to confident practice

24 chapters · Your own pace

0 of 24 chapters complete