Kolam Ayer MakersLinux Foundations

File Compression And Archives

Core Idea

An archive groups files. Compression makes bytes smaller. These are related but not the same. A .tar file is usually an archive. .gz and .bz2 are compression formats. A .tar.gz file is both: tar archive first, gzip compression around it.

Always Identify First

file unknown

Do not guess the decoder from the filename. Filenames can lie, especially in puzzles.

Safe Archive Workflow

mkdir -p ~/extract-work
tar -tf archive.tar
tar -xf archive.tar -C ~/extract-work
find ~/extract-work -maxdepth 2 -type f -print

List before extracting. Extract into a scratch directory so an archive cannot spray files across your current workspace.

Compression Workflow

gzip -d file.gz
bzip2 -d file.bz2
base64 -d encoded.txt > decoded.bin

Decompression tools often replace the compressed file with the decompressed output. Work on copies when experimenting.

Common Confusions

Proof Check

Given an unknown file, run file first, choose the next command, and write down why that command fits the reported type.

Docs Pointers