Compress and decompress files on linux

  • 28 Sep, 2011

Compressing and decompressing files on linux gzip {filename} Gzip compress the size of the given files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz. gzip mydata.doc
gzip *.jpg bzip2 {filename} bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by bzip command (LZ77/LZ78-based compressors). Whenever possible, each file is replaced by one with the extension .bz2. bzip2 mydata.doc
bzip2 *.jpg zip {.zip-filename} {filename-to-compress} zip is a compression and file packaging utility for Unix/Linux. Each file is stored in single .zip {.zip-filename} file with the extension .zip. zip mydata.zip mydata.doc
zip data.zip *.doc tar -zcvf {.tgz-file} {files}
tar -jcvf {.tbz2-file} {files} The GNU tar is archiving utility but it can be use to compressing large file(s). GNU tar supports both archive compressing through gzip and bzip2. If you have more than 2 files then it is recommended to use tar instead of gzip or bzip2. **
-z**: use gzip compress **
-j**: use bzip2 compress tar -zcvf data.tgz *.doc
tar -zcvf pics.tar.gz *.jpg *.png
tar -jcvf data.tbz2 *.doc Decompressinggzip -d {.gz file}
gunzip {.gz file} Decompressed a file that is created using gzip command. File is restored to their original form using this command. gzip -d mydata.doc.gz
gunzip mydata.doc.gz bzip2 -d {.bz2-file}
bunzip2 {.bz2-file} Decompressed a file that is created using bzip2 command. File is restored to their original form using this command. bzip2 -d mydata.doc.bz2
gunzip mydata.doc.bz2 unzip {.zip file} Extract compressed files in a ZIP archive. unzip file.zip
unzip data.zip resume.doc tar -zxvf {.tgz-file}
tar -jxvf {.tbz2-file} Untar or decompressed a file(s) that is created using tar compressing through gzip and bzip2 filter tar -zxvf data.tgz
tar -zxvf pics.tar.gz *.jpg
tar -jxvf data.tbz2

The table above is from this link

Related Posts

Error when run dnf install rpm-build

  • 31 Mar, 2025

I was installing the IBM MQ Server on a linux box yesterday. I got the error bellow: \root@gateway MQServer\ dnf install rpm-build
Updating Subscription Management repositories.
Instana 14 B/s |

Error when run dnf install rpm-buildRead More

How to Install watch on macOS Sequoia

  • 06 Feb, 2025

The watch command is a useful utility in Unix-like systems that allows you to execute a command periodically and display its output. However, macOS does not come with watch pre-installed. If you're ru

How to Install watch on macOS SequoiaRead More

rsync is faster than scp to copy files between machines

  • 31 Dec, 2024

rsync is generally faster than scp for copying files, especially when transferring a large amount of data or syncing directories. Here's why: 1. Incremental Transfers - rsync: Only transfers the p

rsync is faster than scp to copy files between machinesRead More