Working with compression utilities Tar, Gzip, Bzip2, Zip ...




## Use of Tar, Gzip, Bzip2, Zip ##
========================

gzip & gunzip:
----------------

gzip - compresses files
gunzip - decompresses gzip files


How to compress 'seq.txt' file using gzip,

#gzip <source file> <Sourcefile.gz>
#gzip seq.txt seq.txt.gz OR
#gzip -c seq.txt > seq.txt.gz (gzip will redirect this file to seq.txt.gz file)

How to uncompress 'seq.txt' file using gunzip,

        #gunzip seq.txt.gz - dumps to file, and removes compressed version


bzip2 & bunzip2:
------------------

bzip2 - compresses files
bunzip2 - decompresses .bz2 files


How to compress 'seq.txt' file using bzip2,

#bzip2 <source file> <Sourcefile.bz2>
#bzip2 seq.txt seq.txt.bz2 OR
#bzip2 -c seq.txt > seq.txt.bz2 (bzip2 will redirect this file to seq.txt.bz2 file)

How to uncompress 'seq.txt' file using bunzip2,

        #bunzip2 seq.txt.bz2 - dumps to file, and removes compressed version


zip & unzip:
-------------

#zip seq.zip <Folder name to compress>
#zip seq.txt.zip seq.txt

To unzip a file or folder,

#unzip seq.txt.zip


tar with gzip/bzip2:
---------------------

To compress:

#tar -cvf filename.tar /root/test/ (creates a non-compressed archive of a folder /root/test)
  #tar -cvf seq.txt.tar seq.txt (Creates tar file)
#tar -czvf seq.txt.tar.gz seq.txt (creates tar/gzip file)
#tar -cjvf seq.txt.tar.bz2 seq.txt (creates tar/bzip2 file)
#tar -cjvf seq.txt.tar.bz2 seq.txt /root  (creates tar/bzip2 file for the text file and '/root' directory tree)



To extract files:

#tar -xvf filename.tar
#tar -zxvf filename.tar (To uncompress file tarred with gzip or bzip2)


Comments

Post a Comment

Popular posts from this blog

Recover or restore initramfs file in RHEL or CentOS 7

Space reclamation / UNMAP on RHEL or CentOS 7

How to recover /boot partition on RHEL or CentOS 7?