Nov 032006
 

Sponsored Link

Create and Extract .bz2 Files

Introduction

bzip2 and bunzip2 are file compression and decompression utilities. The bzip2 and bunzip2 utilities are newer than gzip and gunzip and are not as common yet, but they are rapidly gaining popularity. The bzip2 utility is capable of greater compression ratios than gzip. Therefore, a bzip2 file can be 10-20% smaller than a gzip version of the same file. Usually,files that have been compressed by bzip2 will have a .bz2 extension.

Installing bzip2 in debian

#apt-get install bzip2

Installing bzip2 in ubuntu

sudo apt-get install bzip2

Uncompressing a bzip2 File Using bunzip2 in Debian

To uncompress a bzip2 file, execute the following command

#bunzip2 filename.txt.bz2 (where filename.txt.bz2 is the name of the file you wish to uncompress)

The result of this operation is a file called filename.txt. By default, bunzip2 will delete the filename.txt.bz2 file.

Compressing a File Using bzip2

To compress a file using bzip2, execute the following command:

#bzip2 filename.txt (where filename.txt is the name of the file you wish to compress)

The result of this operation is a file called filename.txt.bz2. By default, bzip2 will delete the filename.txt file.

Uncompressing a bzip2 File Using bunzip2 in Ubuntu

To uncompress a bzip2 file, execute the following command

sudo bunzip2 filename.txt.bz2 (where filename.txt.bz2 is the name of the file you wish to uncompress)

The result of this operation is a file called filename.txt. By default, bunzip2 will delete the filename.txt.bz2 file.

Compressing a File Using bzip2

To compress a file using bzip2, execute the following command:

sudo bzip2 filename.txt (where filename.txt is the name of the file you wish to compress)

The result of this operation is a file called filename.txt.bz2. By default, bzip2 will delete the filename.txt file.

Available Options

bzip2 --help

bzip2, a block-sorting file compressor. Version 1.0.2, 30-Dec-2001.

usage: bzip2 [flags and input files in any order]

-h --help print this message
-d --decompress force decompression
-z --compress force compression
-k --keep keep (don't delete) input files
-f --force overwrite existing output files
-t --test test compressed file integrity
-c --stdout output to standard out
-q --quiet suppress noncritical error messages
-v --verbose be verbose (a 2nd -v gives more)
-L --license display software version & license
-V --version display software version & license
-s --small use less memory (at most 2500k)
-1 .. -9 set block size to 100k .. 900k
--fast alias for -1
--best alias for -9If invoked as `bzip2′, default action is to compress.as `bunzip2′, default action is to decompress.as `bzcat', default action is to decompress to stdout.

If no file names are given, bzip2 compresses or decompresses from standard input to standard output. You can combine short flags, so `-v -4′ means the same as -v4 or -4v, &c.

If you want more option you need to check bzip2 man page

Create and Extract .gz Files

Introduction

gzip and gunzip are GNU file compression and decompression utilities. Usually, files that have been compressed by gzip will have a .gz extension. However, sometimes you may see a file that has a .tgz extension. This is a TAR file that has been compressed by gzip. The .tgz extension is a shorthand version for the .tar.gz extension. This type of file must be uncompressed with gunzip before it can be untarred. However, there is a way to use the tar command to uncompress the file and untar it at the same time. For more information, see the tar: Tape Archive Files guide.

Installing gzip in Debian

#apt-get install gzip

Installing gzip in Ubuntu

sudo apt-get install gzip

Uncompressing a gzip File Using gunzip in Debian

To uncompress a gzip file, execute the following command:

#gunzip filename.txt.gz (where filename.txt.gz is the name of the file you wish to uncompress)

The result of this operation is a file called filename.txt. By default, gunzip will delete the filename.txt.gz file.

Compressing a File Using gzip

To compress a file using gzip, execute the following command:

#gzip filename.txt (where filename.txt is the name of the file you wish to compress)

The result of this operation is a file called filename.txt.gz. By default, gzip will delete the filename.txt file.

Uncompressing a gzip File Using gunzip in Ubuntu

To uncompress a gzip file, execute the following command:

sudo gunzip filename.txt.gz (where filename.txt.gz is the name of the file you wish to uncompress)

The result of this operation is a file called filename.txt. By default, gunzip will delete the filename.txt.gz file.

Compressing a File Using gzip

To compress a file using gzip, execute the following command:

sudo gzip filename.txt (where filename.txt is the name of the file you wish to compress)

The result of this operation is a file called filename.txt.gz. By default, gzip will delete the filename.txt file.

Available Options

gzip -h
gzip 1.3.5
(2002-09-30)
usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
-c --stdout write on standard output, keep original files unchanged
-d --decompress decompress
-f --force force overwrite of output file and compress links
-h --help give this help
-l --list list compressed file contents
-L --license display software license
-n --no-name do not save or restore the original name and time stamp
-N --name save or restore the original name and time stamp
-q --quiet suppress all warnings
-r --recursive operate recursively on directories
-S .suf --suffix .suf use suffix .suf on compressed files
-t --test test compressed file integrity
-v --verbose verbose mode
-V --version display version number
-1 --fast compress faster
-9 --best compress better
--rsyncable Make rsync-friendly archive

file... files to (de)compress. If none given, use standard input.

If you want more option you need to check gzip man page

Sponsored Link

 Posted by at 10:00 pm
  • http://www.arky.in Arky

    Our good old ‘tar’ also works with Bunzip2 (-j, –bzip2) and Gzip(-z, –gzip, –gunzip, –ungzip) compression formats.

    Cheers

    –arky

  • santosh

    please help me how to extract img.gz file in ubuntu 10.04 version