Compression & Archiving
| Description | Commands |
|---|---|
| Daily drivers | tar, gzip, gunzip, zip, unzip |
| Alternative compression | bzip2, bunzip2, compress, uncompress |
| Archive management | cpio, ar, rar, unrar |
| Viewing/searching compressed files | zcat, zless, zdiff, zgrep, zipinfo, bzcat, bzdiff, bzgrep, bzless, bzmore |
Daily Driver
tar
Usage : tar -cvf archive.tar files/
Example : tar -xvf archive.tar.gz
Description : Create and extract archives (optionally compressed).
Takeaway : Use for bundling multiple files into one archive, often combined with compression (gzip, bzip2).gzip
Usage : gzip file.txt
Example : gzip access.log
Description : Compress files using GNU zip.
Takeaway : Use for fast, efficient single-file compression.gunzip
Usage : gunzip file.gz
Example : gunzip access.log.gz
Description : Decompress .gz files.
Takeaway : Use to restore files compressed with gzip.zip
Usage : zip archive.zip file1 file2
Example : zip -r project.zip project/
Description : Create compressed ZIP archives.
Takeaway : Use for cross-platform compression (Windows/Linux).unzip
Usage : unzip archive.zip
Example : unzip project.zip -d /tmp
Description : Extract files from ZIP archives.
Takeaway : Use to unpack ZIP files, including password-protected ones.Compression Utilities
bzip2
Usage : bzip2 file.txt
Example : Compress large log file.
Description : Compress files with higher ratio than gzip.
Takeaway : Use for better compression efficiency.bunzip2
Usage : bunzip2 file.bz2
Example : bunzip2 archive.tar.bz2
Description : Decompress .bz2 files.
Takeaway : Use to restore files compressed with bzip2.compress
Usage : compress file.txt
Example : compress olddata.log
Description : Legacy compression utility.
Takeaway : Rarely used; replaced by gzip.uncompress
Usage : uncompress file.Z
Example : uncompress archive.Z
Description : Decompress files compressed with compress.
Takeaway : Use only for legacy .Z files.RAR Utilities
rar
Usage : rar a archive.rar files/
Example : Compress folder into RAR.
Description : Create RAR archives.
Takeaway : Use for RAR compression (requires external package).unrar
Usage : unrar x archive.rar
Example : Extract multi-part RAR file.
Description : Extract RAR archives.
Takeaway : Use to unpack RAR archives.ZIP File Utilities
zipinfo
Usage : zipinfo archive.zip
Example : List files inside ZIP.
Description : Show contents of ZIP archives.
Takeaway : Use for analyzing ZIP contents.Archive Management
cpio
Usage : cpio -ov < filelist > archive.cpio
Example : cpio -idv < archive.cpio
Description : Copy files to/from archives.
Takeaway : Use for backup/restore tasks.ar
Usage : ar rcs libfoo.a foo.o
Example : Build static library for C programs.
Description : Create/manage static libraries.
Takeaway : Use for software development (library management).
Updated on Dec 23, 2025