Skip to main content

Compression and Decompressing

Get file extension

file unknownfiletype.bin
unknownfiletype.bin: gzip compressed data, was “data2.bin”, last modified: Thu May 7 18:14:30 2020, max compression, from Unix


Decompress Tarball

tar xf file3.tar

Extract .tar.gz file to current working directory and print output:

tar -xvf file4.tar.gz

Decompress gzip

gzip -d file.gz

Decompress bzip2

bzip2 -d file2.bz2

Decompress .tar.gz file with gzip:

gzip -d file5.tar


using tar

tar czf <archive name>.tar.gz <file(s) or location(s)>

Using gzip

Compressing Files with gzip

gzip filename

Compressing Files with gzip. Keep the original file

gzip -k filename

Compress multiple files

gzip file1 file2 file3

using bzip2

bzip2 -z file.txt