Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

15.3. Compression

There are two main compression utilities used in GNU/Linux. It's normal to first "tar" a bunch of files (using the tar program of course) and then compress them with either bzip2 or gzip. Of course either of these tools could be used without tar, although they are not designed to work on more than one file (they use the UNIX tools philosophy, let tar group the files, they will do the compression...this simplifies their program). It's normal to use tar and then use these tools on them, or use tar with the correct options to use these compression programs.

GNU zip (gzip)

gzip is the GNU zip compression program and probably the most common compression format on UNIX-like operating systems.

gzip your_tar_file.tar

This will compress a tar archive with GNU zip, usually with a .gz extension. Gzip can compress any type of file, it doesn't have to be a tar archive.

gunzip your_file.gz 

This will decompress a gzipped file, and leave the contents in the current directory.

bzip2

bzip2 is a newer compression program which offers superior compression to gzip at the cost of more processor time.

bzip2 your_tar_file.tar 

This will compress a tar archive with the bzip2 compression program, usually with a .bz extension. bzip2 can compress any type of file, it doesn't have to be a tar archive.

bunzip2 your_file.tar.bz2 

This will decompress a file compressed by bzip2, and leave the contents in the current directory.

zipinfo Use zipinfo to find detailed information about a zip archive (the ones usually generally used by ms-dos and windows, for example winzip).

Command syntax:

zipinfo zip_file.zip

zipgrep Will run grep to look for files within a zip file (ms-dos style, for example winzip) without manually decompressing the file first.

Command syntax:

zipgrep pattern zip_file.zip

bzip2recover Used to recover files from a damaged bzip2 archive. It simply extracts out all the working blocks as there own bzip2 archives, you can than use bzip2 -t on each file to test the integrity of them and extract the working files.

bzme Will convert a file that is zipped or gzipped to a file compressed using bzip2.

Command syntax:

bzme filename
Tip Tip
 

Both gzip and bzip2 supply tools to work within compressed files for example listing the files within the archive, running less on them, using grep to find files within the archive et cetera.

For gzip the commands are prefixed with z, zcat, zless, zgrep.

For bzip2 the commands are prefixed with bz, bzcat, bzless, bzgrep.

 
 
  Published under the terms of the GNU General Public License Design by Interspire