top of page
Writer's pictureMukesh Chanderia

Linux - Commands Part 9 - Gun zip, Bun zip & XZ

Updated: Aug 21, 2021

Let us check the size of tar file which we created by compressing "/etc"

[root@RedHat7 Mydata]# du -sh Redhat.tar

32M Redhat.tar


Now let's try to create the following compressed file with "tar" command


A) Tar with Gunzip


[root@RedHat7 Mydata]# tar -zcvf Redhat.gz /etc -⇾ Here /etc directory is being compressed


So you can see how powerful is to compress file with Gunzip


[root@RedHat7 Mydata]# du -sh *

36M etc

11M Redhat.gz <-- Compressed with tar of /etc

32M Redhat.tar <-- Tar File of /etc


Extract : Just use "x" in place of "c"


[root@RedHat7 Mydata]# tar -zxvf Redhat.gz


B) Tar with Bunzip (use "j" instead of z)


[root@RedHat7 Mydata]# tar -jcvf Redhat.bz2 /etc

/etc/delhi

[root@RedHat7 Mydata]# du -sh *

36M etc

9.4M Redhat.bz2

11M Redhat.gz

32M Redhat.tar

To Extract

[root@RedHat7 Mydata]# tar -jxvf Redhat.bz2

---------------------------------------------

C) Tar with XZ method


[root@RedHat7 Mydata]# tar -Jcvf Redhat.xz /etc

[root@RedHat7 Mydata]# du -sh *

36M etc

9.4M Redhat.bz2

11M Redhat.gz

32M Redhat.tar

7.7M Redhat.xz


Extract :

[root@RedHat7 Mydata]# tar -Jxvf Redhat.xz


ZIP


[root@RedHat MyData]# ls

etc


So let's compress "/etc" which is present in directory MyData


[root@RedHat MyData]# zip etcdirectory.zip etc

adding: etc/ (stored 0%)


[root@RedHat MyData]# ls

etc etcdirectory.zip


[root@RedHat MyData]# du -sh *

24M etc

4.0K etcdirectory.zip -⇾ How Powerful is Zip in Linux

Unzip

[root@RedHat MyData]# unzip etcdirectory.zip

Archive: etcdirectory.zip

creating: etc/

[root@RedHat MyData]# ls

etc etcdirectory.zip

168 views0 comments

Comments


bottom of page