A
cd ..
System

Compression & Archives

zip, gzip, bzip2, and other compression tools for files and directories.

2025-09-13
compression, zip, linux

Create zip archive

zip -r archive.zip folder/

Extract zip archive

unzip archive.zip

List contents without extracting

unzip -l archive.zip

Extract to specific directory

unzip archive.zip -d /target/directory

Gzip compress file

gzip file.txt

Creates file.txt.gz and removes original.

Gzip decompress

gunzip file.txt.gz

Or:

gzip -d file.txt.gz

Keep original file when compressing

gzip -k file.txt

Compress with bzip2 (better compression)

bzip2 file.txt

Decompress bzip2

bunzip2 file.txt.bz2

Create tar.gz archive

tar -czvf archive.tar.gz folder/

Extract tar.gz

tar -xzvf archive.tar.gz

Create tar.bz2 (better compression)

tar -cjvf archive.tar.bz2 folder/

Extract tar.bz2

tar -xjvf archive.tar.bz2

View tar contents

tar -tzvf archive.tar.gz

Extract single file from tar

tar -xzvf archive.tar.gz file.txt

7zip compression (maximum)

7z a -t7z -mx=9 archive.7z folder/

Extract 7z

7z x archive.7z

Was this useful?

Share with your team

Browse More