1. Zip
Following are the main compression utilities that are available π
Format for zipping the files:Β zip <filename> <source_files>
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# zip test.zip test1.txt test2.txt test3.txt
adding: test1.txt (deflated 92%)
adding: test2.txt (deflated 92%)
adding: test3.txt (deflated 92%)
[root@kalwa2 zip_test]# ll
total 16
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 511 Jun 14 09:10 test.zip
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
Β
Format for UNzipping the files:Β unzip <filename>.zip
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 16
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 511 Jun 14 09:10 test.zip
[root@kalwa2 zip_test]# rm -f *.txtΒ
Note: Removing txt files for better understanding of the topic please do not perform this command in your environment.
[root@kalwa2 zip_test]# ll
total 4
-rw-rβrβ. 1 root root 511 Jun 14 09:10 test.zip
[root@kalwa2 zip_test]# unzip test.zip
Archive: test.zip
inflating: test1.txt
inflating: test2.txt
inflating: test3.txt
[root@kalwa2 zip_test]# ll
total 16
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 511 Jun 14 09:10 test.zip
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β
2. gzipΒ
Format for zipping the files: gzip
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]# gzip test1.txt test2.txt test3.txt
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 45 Jun 14 09:02 test1.txt.gz
-rw-rβrβ. 1 root root 45 Jun 14 09:02 test2.txt.gz
-rw-rβrβ. 1 root root 45 Jun 14 09:03 test3.txt.gz
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
Format for GUNzipping the files: gunzip .gz
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 45 Jun 14 09:02 test1.txt.gz
-rw-rβrβ. 1 root root 45 Jun 14 09:02 test2.txt.gz
-rw-rβrβ. 1 root root 45 Jun 14 09:03 test3.txt.gz
[root@kalwa2 zip_test]# gunzip test1.txt.gz
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 45 Jun 14 09:02 test2.txt.gz
-rw-rβrβ. 1 root root 45 Jun 14 09:03 test3.txt.gz
[root@kalwa2 zip_test]# gunzip test2.txt.gz test3.txt.gz
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
3. Β bzip2Β
Format for zipping the files: bzip2
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]# bzip2 test1.txt test2.txt test3.txt
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 66 Jun 14 09:02 test1.txt.bz2
-rw-rβrβ. 1 root root 66 Jun 14 09:02 test2.txt.bz2
-rw-rβrβ. 1 root root 66 Jun 14 09:03 test3.txt.bz2
ββββββββββEND OF OUTPUTβββββββββββββββ
Format for BUNzipping the files: bunzip2 .bz2
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 66 Jun 14 09:02 test1.txt.bz2
-rw-rβrβ. 1 root root 66 Jun 14 09:02 test2.txt.bz2
-rw-rβrβ. 1 root root 66 Jun 14 09:03 test3.txt.bz2
[root@kalwa2 zip_test]# bunzip2 test1.txt.bz2
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 66 Jun 14 09:02 test2.txt.bz2
-rw-rβrβ. 1 root root 66 Jun 14 09:03 test3.txt.bz2
[root@kalwa2 zip_test]# bunzip2 test2.txt.bz2 test3.txt.bz2
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
4. Tar commands:
Format for doing the tar fromΒ Β the files:Β tar -cvf .tar
ββββββββββOUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
[root@kalwa2 zip_test]# tar -cvf test.tar test1.txt test2.txt test3.txt
test1.txt
test2.txt
test3.txt
[root@kalwa2 zip_test]# ll
total 24
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
Β Format for doing the untar fromΒ Β the files: tar -xvf
βββββββββ-OUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# ll
total 24
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]# rm -f *.txtΒ
Note: Removing txt files for better understanding of the topic please do not perform this command in your environment.
[root@kalwa2 zip_test]# ll
total 12
-rw-rβrβ. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
[root@kalwa2 zip_test]# tar -xvf test.tar
test1.txt
test2.txt
test3.txt
[root@kalwa2 zip_test]# ll
total 24
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test1.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:02 test2.txt
-rw-rβrβ. 1 root root 221 Jun 14 09:03 test3.txt
-rw-rβrβ. 1 root root 10240 Jun 14 09:49 test.tar
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
For checking the contents of the tar file use commandΒ tar -tvf
βββββββββ-OUTPUTββββββββββββββββββ-
[root@kalwa2 zip_test]# tar -tvf test.tar
-rw-rβrβ root/root 221 2015-06-14 09:02 test1.txt
-rw-rβrβ root/root 221 2015-06-14 09:02 test2.txt
-rw-rβrβ root/root 221 2015-06-14 09:03 test3.txt
[root@kalwa2 zip_test]#
ββββββββββEND OF OUTPUTβββββββββββββββ
Β