Data compression is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compression reduces bits by identifying and eliminating statistical redundancy. No information is lost in lossless compression. Lossy compression reduces bits by removing unnecessary or less important information. Typically, a device that performs data compression is referred to as an encoder, and one that performs the reversal of the process (decompression) as a decoder. The process of reducing the size of a data file is often referred to as data compression. In the context of data transmission, it is called source coding; encoding done at the source of the data before it is stored or transmitted. Source coding should not be confused with channel coding, for error detection and correction or line coding, the means for mapping data onto a signal. The gzip command compresses files. Each single file is compressed into a single file. The compressed file consists of a GNU zip header and deflated data. Syntax: Command Options:
In the following example, the .txt file is compressed; notice that the original file is no longer present, but copy the compressed file. pbmac@pbmac-server $ ls myFile.txt myFile.txt pbmac@pbmac-server $ gzip myFile.txt pbmac@pbmac-server $ ls myFile.txt* myFile.txt.gz
XZ Utils is a set of free software command-line lossless data compressors, including lzma and xz, for Linux operating systems. xz achieves higher compression rates than alternatives like gzip and bzip2. Decompression speed is faster than bzip2, but slower than gzip. Compression can be much slower than gzip, and is slower than bzip2 for high levels of compression, and is most useful when a compressed file will be used many times. XZ Utils consists of two major components:
Various command shortcuts exist, such as lzma (for xz --format=lzma), unxz (for xz --decompress; analogous to gunzip) and xzcat (for unxz --stdout; analogous to zcat). XZ Utils can compress and decompress both the xz and lzma file formats, but since the lzma format is now legacy, XZ Utils compresses by default to xz.
The bzip2 command is used to compress and decompress the files i.e. it helps in binding the files into a single file which takes less storage space than the original file used to take. It has a slower decompression time and higher memory use. It uses Burrows-Wheeler block sorting text compression algorithm, and Huffman Coding. Each file is replaced by a compressed version of itself, with the original name of the file followed by extension bz2. bzip2 is actually part of a larger suite of commands all based around this compression algorithm. The other commands that are a part of this suite are listed in the table below:
The zip command is a compression and file packaging utility for Unix. Each file is stored in single .zip {.zip-filename} file with the extension .zip.
Syntax: Command Options:
To create a zip file you specify the zip file name, followed by the files to include in the zip file: pbmac@pbmac-server $ zip myfile.zip filename.txt otherfile.txt picture.jpgExtracting files from zip file Unzip will list, test, or extract files from a zip archive, commonly found on Unix systems. The default behavior (with no options) is to extract into the current directory (and sub-directories below it) all files from the specified zip archive. pbmac@pbmac-server $ unzip myfile.zipAdapted from: |