Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Tuesday 10 December 2013

tar/untar, gzip/gunzip, compress/uncompress, pack/unpack and zip/unzip


               
Command Name
Reverse
Output filename
gzip
gunzip
(*.gz)
compress
uncompress
(*.z)
pack
unpack
(*.Z)
winzip (Zip in windows)
unzip
(*.zip)
tar
tar –xvf
(*.tar)



tar/untar
Purpose: Manipulates archives.
# tar  -cvf  /home/test1.tar  /test1                         Archives files /test1 directory and create test1.tar file.
                                      |                      | ---------------- > source directory
                                      |-----------------------------------> Destination file

where
-c    Creates a new archive and writes the files specified by one or more File parameters       to the beginning of the archive.
-v    Lists the name of each file as it is processed.
-f    Archive Uses the Archive variable as the archive to be read or written. When this       flag is not specified, the tar command uses a system-dependent default file name of       the form /dev/rmt0.
-t    Lists the files in the order in which they appear in the archive.
-x    Extracts the files specified by one or more File parameters from the archive.


List
# tar –tvf    test1.tar                                                     List the contents of test1.tar file
Extract
# tar –xvf  /backup /home/test1.tar                     extract the test1.tar file
Examples:
# tar -cvf  alldoc.tar  *.doc                                         tar all *.doc files and make the new file alldoc.tar
# tar  -tvf alldoc.tar                                                    List the new alldoc.tar file.
# tar -cvf project.tar project                                     Create a project.tar file of a directory called project.

gzip/gunzip
gzip   
Purpose: Compress file. This will create *.gz extension file. gzip  reduces  the  size  of  the  named  files using Lempel-Ziv coding(LZ77).  Whenever possible, each file  is  replaced  by  one  with  the extension .gz, while keeping the same ownership modes, access and modi-fication times.
# gzip server1.mksysb                                                 This will compress and create server1.mksysb.gz file on the same location.
Note: This will replace the server1.mksysb file with server1.mksysb.gz file.
gunzip
# gunzip server1.mksysb.gz                                      This will unzip the file server1.mksysb.gz to orignal server1.mksysb file on same location.
Note: After gunzip server1.mksysb.gz will replace with server1.mksysb file.

    
compress/uncompress   
compress
Purpose: Compress file and this will create *.Z(Capital Z) extension file.
# compress -v server1.mksysb                                                This will compress the server1.mksysb file to server1.mksysb.Z file.
Note: -v switch tells how much file is compress in percentage (%).
Some time it split error like "This file is not changed; compression does not save space".
uncompress
# uncompress -v server1.mksysb.Z                       Will uncompress the file server1.mksysb.Z to orignal file which is                                                                                                             server1.mksysb.
Note: Due to higher compression ratio gzip/gunzip is preffered over compress/uncompress.

pack/unpack
pack
Purpose: Compresses files. This will create *.z (small z) extension file.
# pack -  server1.mksysb 
      pack: server1.mksysb.z: This file is reduced in size 5.5%.
              The file changed from 872887502 to 873241248 bytes.
              The Huffman tree has 10 levels below the root.
              There are 256 distinct bytes in input.
              The dictionary overhead is 273 bytes.
              The effective entropy is 7.56 bits per byte.
              The asymptotic entropy is 7.56 bits per byte.

#
# ls -ltr 
-rw-r--r--    1 root     system    873241248 Jun 08 2012  server1.mksysb.z
#


unpack
Lets unpack it
# unpack server1.mksysb.z 
unpack: server1.mksysb.z: This file is now unpacked.
#
# ls -ltr 
-rw-r--r--    1 root     system    873241248 Jun 08 2012  server1.mksysb
#

zip/unzip
To unzip windows zip file in aix, make sure you have install the unzip rpm, if this does not have in your computer.
# unzip
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler. Sendbug reports using http://www.info-zip.org/zip-bug.html; see README for details.
…..
Lets unzip a windows winzip file e.g test1.zip
# unzip test1.zip
Archive:  test1.zip
  inflating: Memory/general.txt
…..  

No comments:

Post a Comment