Tar Archives

Create and extract tar archives.

tar -cvf archive.tar files/
tar -czvf archive.tar.gz files/
tar -cjvf archive.tar.bz2 files/
tar -xvf archive.tar
tar -xzvf archive.tar.gz
tar -tvf archive.tar

Zip Files

Create and extract zip archives.

zip -r archive.zip directory/
unzip archive.zip
unzip archive.zip -d /path/
unzip -l archive.zip

Gzip Compression

Compress with gzip.

gzip file.txt
gunzip file.txt.gz
gzip -k file.txt
gzip -d file.txt.gz

Bzip2

Better compression ratio.

bzip2 file.txt
bunzip2 file.txt.bz2
bzip2 -k file.txt

7zip

High compression archiver.

7z a archive.7z files/
7z x archive.7z
7z l archive.7z

Rar

RAR archive operations.

unrar x archive.rar
unrar l archive.rar

Common mistakes / Pitfalls

  • People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
  • It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
  • Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026