Facebook
Banner
XMPP JavaScript Library READ MORE

File compression, decompression in Linux

Linux, Sachin Puri, 2012-02-03 14:40:49

There are number of tools available in Linux to compress and decompress data.

Compression UnCompressing Extension
zip  unzip .zip
gzip  gunzip, gzip -d .gz
tar -cvf tar -xvf .tar
pack unpack .z
bzip2 bunzip2 .bz2

 

How to check if tools are installed in Linux box

You can check which of this tool is already installed in your system by running "which" command in linux command shell.

Syntex

which <tool-name>

Example

which gzip

On Sucess: This will output the location where gzip tools is installed like:- /bin/gzip

On Failure: This will output something like following

/usr/bin/which: no gzip in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin)

 

 

Using gzip to compress files in linux

If gzip is installed in your system, you can use following command in Linux command shell to compress a file.

Syntex:-

gzip <filename>

Example

gzip filename.log

 

 

Using gunzip to decompress files in linux

To unzip a file in Linux command shell use following command

Syntex:-

gunzip <filename>

Example

gunzip filename.gz

 

 

Using gzip -d to decompress files in linux

If gunzip is not availabel you can make use of gzip -d to unzip a file in Linux.

Syntex:-

gzip -d <filename>

Example

gunzip -d filename.gz

where,

-d = decompress

 

Using tar to compress a directory in Linux

run following command to compress a directory

Syntex:-

tar -cvf <filename.tar> <path-to-directory>

Example

tar -cvf example.tar /home/user1


Where,

c - create

v - verbose

f - archive file name

 

 

Add Your Comment
   
    Yes! I want to receive all comments by email

No Comments Posted Yet. Be the first one to post comment