Linux Admin Part12 Compress and Archive gzip, bzip2 and tar

Published: 12 February 2022
on channel: Latif Shaik
28
0

20220212 162125
Archive:

windows - compress- .zip
- winrar - .rar

Linux - tar

tar+compress

tar+gzip - tar.gz - .tgz

tar+bzip2 -tar.bz2 - .tbz2

man tar

pinfo tar

tar --help
----------------

tar -cf archive.tar foo bar
Create archive.tar from files foo and bar.

tar -tvf archive.tar
List all files in archive.tar verbosely.

tar -xf archive.tar
Extract all files from archive.tar.

--------------------
-j, --bzip2
filter the archive through bzip2

-J, --xz
filter the archive through xz
-z, --gzip
filter the archive through gzip
--------------------
-v, --verbose
verbosely list files processed

-----
data1
archive tar - data1.tar
compress gzip - data1.tar.gz

tar+gzip -czf -create data1 - data1.tar.gz
-xzf -extract data1.tar.gz --data1

tar+bzip2 -cjf -create data1 - data1.tar.bz2
-xjf -extract data1.tar.bz2 --data1

---

mkdir datat1
dd if=/dev/zero of=datat1/tf1 bs=1024 count=1024
dd if=/dev/zero of=datat1/tf2 bs=1024 count=1024
dd if=/dev/zero of=datat1/tf3 bs=1024 count=1024
dd if=/dev/zero of=datat1/tf4 bs=1024 count=1024
dd if=/dev/zero of=datat1/tf5 bs=1024 count=1024
ls -lh datat1/
du -h datat1/

create archive on data1

tar -cf datat1.tar datat1/

du -h datat1/
du -h datat1.tar

tar tvf datat1.tar

tar xvf datat1.tar --extract in same location


[root@ ~]# ls
abc data3 Documents file4 Music sfile1
anaconda-ks.cfg datat1 Downloads gfile1 of11 Templates
cf1 datat1.tar file1 hfile1 Pictures Videos
data2 Desktop file3 initial-setup-ks.cfg Public xyz

[root@ ~]# tar xvf datat1.tar -C data3/ --extract in different location -data3/
datat1/
datat1/tf1
datat1/tf2
datat1/tf3
datat1/tf4
datat1/tf5
[root@ ~]# ls data3
da3 data1 data2 datat1

[root@ ~]# ls data3/datat1/
tf1 tf2 tf3 tf4 tf5


gzip datat1.tar

ls -l datat1.tar.gz
-rw-r--r--. 1 root root 5440 Feb 12 16:55 datat1.tar.gz
du -h datat1.tar.gz
8.0K datat1.tar.gz


gunzip datat1.tar.gz

--------
both archive and compress

tar+bzip2

du -h datat1
5.0M datat1

tar -cjf datat1.tar.bz2 datat1/

ls
abc datat1 Downloads hfile1 Public
anaconda-ks.cfg datat1.tar file1 initial-setup-ks.cfg sfile1
cf1 datat1.tar.bz2 file3 Music Templates
data2 Desktop file4 of11 Videos
data3 Documents gfile1 Pictures xyz
du -b datat1.tar.bz2
205 datat1.tar.bz2

tar xjf datat1.tar.bz2 -C Desktop/

ls Desktop/
ad datat1 file1 file2 file3
ls Desktop/datat1/
tf1 tf2 tf3 tf4 tf5
du -h Desktop/datat1/
5.0M Desktop/datat1/
----------------------------


Watch video Linux Admin Part12 Compress and Archive gzip, bzip2 and tar online without registration, duration hours minute second in high quality. This video was added by user Latif Shaik 12 February 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 28 once and liked it 0 people.