tar/untar, gzip/gunzip, compress/uncompress, pack/unpack
and zip/unzip
Command Name
|
Reverse command name
|
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 Compress files /test1 directory and create
test1.tar 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
Example:
#
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
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 modification
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
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 original file
which is server1.mksysb.
Note: Due to higher compression ratio gzip/gunzip is preffered over
compress/uncompress.
pack/unpack
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
#
Let’s
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.
….. <output omitted>
Lets unzip a windows winzip
file e.g test1.zip
#
unzip test1.zip