KandZ – Tuts

We like to help…!

Linux CLI 38 🐧 gzip and bzip2 commands

a - gzip command

gzip is used to compress and decompress files
Files compression helps on saving disk space and ...
... trasfering files faster. use -k to keep the original file
note that gzip cannot compress a folder. You can combine find and gzip
find /directory/to/compress -type f -exec gzip {} \;
or ls -l /directory/to/compress | gzip foo.txt.gz
gzip file.txt → compresses one file
gzip -d file.txt.gz → decompresses one file
gzip -v file.txt file1.txt → compresses multiple files


b - bzip2 command

bzip2 is used to compress and decompress files
like gzip, bzip2 deletes the original file. Use -k to keep it
.bz2 extension shows that it is a compress file with bzip2
bzip2 -k 1.txt → compresses a file and keep the original
bzip2 -d 1.txt.bz2 → decompresses a file
bzip2 -d -f 1.txt.bz2 → decompreses a file and overwrite
bzip2 -k 1.txt 2.txt → compresses multiple files in multiple files
bzmore 1.txt.bz2 → show information of the compressed file

Leave a Reply