Showing posts with label tar command in linux. Show all posts
Showing posts with label tar command in linux. Show all posts

Wednesday 10 August 2016

Different Compressed & Uncompressed example in RHEL 7


To create a compressed tar archive, one of the following tar options can be  specified:
- z  for gzip compression (filename.tar.gz or filename.tgz)
- j  for bzip2 compression (filename.tar.bz2)
- J  for xz compression (filename.tar.xz)

Compress /etc directory (using c option) as /root/etcback.tar.gz using following command

[root@saidrasel~]$  tar  czf  /root/etcback.tar.gz  /etc

Compress /etc directory (using j option) as /root/etcback.tar.bz2 using following command

[root@saidrasel~]$  tar  cjf  /root/etcback.tar.bz2  /etc

Compress /etc directory (using J option) as /root/etcback.tar.xz using following command

[root@saidrasel~]$  tar  cjf  /root/etcback.tar.xz  /etc

Extract a compress tar ( x option) archive using following command

[root@saidrasel~]$ mkdir -p /tmp/extract
[root@saidrasel~]$ cd /tmp/extract
[root@saidrasel extract]$  tar  xzf  /root/etcback.tar.gz  

Extract a compress tar ( j) archive using following command

[root@saidrasel~]$ mkdir -p /tmp/extract
[root@saidrasel~]$ cd /tmp/extract
[root@saidrasel extract]$  tar  xjf  /root/etcback.tar.bz2  

Extract a compress tar ( J) archive using following command

[root@saidrasel~]$ mkdir -p /tmp/extract
[root@saidrasel~]$ cd /tmp/extract
[root@saidrasel extract]$  tar  xJf  /root/etcback.tar.xz