Utilities to compress and uncompress files in Linux

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

Utilities to compress and uncompress files in Linux

Rating:

Utilities to compress and uncompress files in Linux

In this article, it is intended to discuss the following utilities that are used to compress and uncompress files in Linux:

  • TAR

  • GZIP & GUNZIP

  • BZIP2 & BUNZIP2
TAR

The TAR (Tape Archive) utility was originally designed for tape backups. It is used to create a TAR file anywhere on the filesystem. The TAR utility does not compress files, but it creates one TAR file out of several files and directories and keeps their absolute path information if required. Hence, a TAR file takes the same amount of space as that of all the individual files (and folders) combined. However, a TAR file can be compressed by using the GZIP or BZIP2 utility.

Syntax

TAR -switch(es) <filename>, where <filename> is the name of the TAR file.

Some important switches used with the TAR command are as follows:

SwitchesDescription
XIt is used to extract the contents of a TAR file.
CIt is used to create a TAR file.
ZIt is used to uncompress a compressed TAR file before extracting.
vIt is used to display the contents while creating a TAR file or extracting from it.
tIt is used to list all the contents of a TAR file.


GZIP & GUNZIP

GZIP and GUNZIP are GNU file compression and decompression utilities. The files that are compressed by GZIP have a .gz extension. If a TAR file is compressed by the GZIP command, the file will have the .tgz extension.

Compressing files with the GZIP command: To compress a file, use the GZIP command as shown below:


GZIP <filename.txt>
where <filename.txt> is the name of the file to be compressed.



After using the command, a file named filename.txt.gz will be created. By default, the GZIP command will delete the filename.txt file.

Uncompressing files with the GUNZIP command: To uncompress a GZIP file, execute the following command:


GUNZIP <filename.txt.gz>
where <filename.txt.gz> is the name of the file to be uncompressed.

After using the command, a file named filename.txt will be created. By default, the GUNZIP command will delete the filename.txt.gz file.

BZIP2 & BUNZIP2

BZIP2 and BUNZIP2 are newer file compression and decompression utilities than GZIP and GUNZIP. The BZIP2 utility maintains greater compression ratios than GZIP to keep the size of compressed file lower. A BZIP2 file can be 10-20 percent smaller than the same file zipped with the GZIP utility. Files that have been compressed by BZIP2 have a .bz2 extension.

BZIP2 and BUNZIP2 are not as common yet, but they are rapidly gaining popularity.

Compressing files with the BZIP command: To compress a file, use the BZIP command as shown below:


BZIP2 <filename.txt>
where <filename.txt> is the name of the file to be compressed.


After using the command, a file named filename.txt.bz2 will be created. By default, the BZIP command will delete the filename.txt file.

Uncompressing files with the BUNZIP command: To uncompress a BZIP file, execute the following command:


BUNZIP2 <filename.txt.bz2>
where <filename.txt.bz2> is the name of the file to be uncompressed.

After using the command, a file named filename.txt will be created. By default, the BUNZIP command will delete the filename.txt.bz2 file.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.