If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
#apt-get install bzip2
Uncompressing a bzip2 File Using bunzip2
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.
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 -9
If 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 using the following command
#man bzip2
Create and Extract .gz Files
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
Uncompressing a gzip File Using gunzip
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.
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 using the following command
#man gzip
You may also be interested in...
April 11th, 2007 at 6:42 pm
Just a couple suggestions, but for trivial utilities, you may want to just mention them as a one-liner and then link to additional documentation, HTML’d man pages like this: http://www.hmug.org/man/1/gzip.php or something more useful like this: http://badcomputer.org/unix/tar.bot . For this article in particular, I would suggest you mention “tar” since it is essential in archiving folders which is as common, if not more common, a task for the average user then archiving single files.
April 14th, 2007 at 12:32 am
I agree, why did you leave the tar command out? I think nowadays tar and gzip or bzip go hand in hand. creating a bzip or gzip file is easy but with tar combined it can be made even nicer, the command is just longer.
My 2 cents
//Flosse
June 20th, 2007 at 11:35 pm
Hey, what have you got against afio?!?
Just kidding.
find /blah -depth -mount -print0 | \afio -z -Z -P bzip2 -0 blah.afio \
-L blah.log
Have fun.
July 4th, 2007 at 8:26 am
You can achieve much better compression ratios using the p7zip package