Sunday, March 12, 2017

RHCE 7 :- tar - an example


Tar
c - create
t - list/view
x - extract


f - specifies file
v - verbose - show detail


backup /etc under /var/tmp/backup

# tar -cvf /destination_location/file.tar /source/file_or_dir
# tar -cvf /var/tmp/backup/myetc.tar /etc

Extra the tar file
# mkdir /tmp/backup
# cd /tmp/backup
# tar -xvf /destination_location/file.tar

Compressing tar
z - zip file with gz extension file
j - bzip2
J - xz

creating tar with compressing file
# tar -czvf /var/tmp/backup/myetc.tar.gz /etc
# tar -cjvf /var/tmp/backup/myetc.tar.bzip2 /etc
# tar -cJvf /var/tmp/backup/myetc.tar.xz /etc

Extract compressed enable tar file
# cd /location_to_extract
# cd /var/tmp/restored
# tar -xzvf /var/tmp/backup/myetc.tar.gz
# tar -xjvf /var/tmp/backup/myetc.tar.bzip
# tar -xJvf /var/tmp/backup/myetc.tar.xz

No comments:

Post a Comment