Menu
Redhat Linux RHCSA RHCE

Lab 5: File Compression

Redhat Linux RHCSA RHCE

Lab 5: File Compression

Data Compression involves 2 steps:

  1. Archiving
  2. Compression

Compression using tar and gzip:

cp –r /usr/bin /tmp     

#To check disk usage of directory                                    
du –h /tmp/bin               

#To create an archive                                  
tar –zcf /root/lallu.tar.gz  /tmp/bin             

#To list contents of an archive
tar –ztvf /root/lallu.tar.gz                                    

#To extract some content
tar –zxf /root/lallu.tar.gz ‘tmp/bin/hostname’ ‘tmp/bin/ls’   

#To extract full content
tar –zxf /root/lallu.tar.gz                                

Compression using tar and bzip2

#To create an archive
tar –jcf /root/lallu.tar.bz2 /tmp/bin         

#To list contents of an archive
tar –jtvf /root/lallu.tar.bz2    
             
#To extract content
tar –jxf /root/lallu.tar.bz2               

Compression using tar and xzip

#To create an archive
tar –Jcf /root/lallu.tar.xz /tmp/bin

#To list contents of archive
tar –Jtvf /root/lallu.tar.xz       

#To extract content
tar –Jxf /root/lallu.tar.xz