Common Linux commands (version 2)-compression and decompression commands
Compression and decompression commands:
----------.Gz ----------
1. Compression
Gzip [GNU zip]:/bin/gzip
Format: gzip option [file]. ZIP file. The extension name is .gz after compression. It is the most common # common software source code package format in Linux.
Features: 1) only files can be compressed and directories cannot be compressed.
2) do not retain the original file
E.g. gzip newfile # Delete the original newfile
2. Decompress
1) gunzip [GNU zip]:/bin/gunzip
2) gzip-d unzip decompress .gz
E. g.
Gzip-d newfile.gz
----------.Tar ----------
3. Compression
Tar:/bin/tar
# Package the Directory and package it into a file to generate .tar. if you compress the directory, .gz will be generated.
Format: tar [Option cvf] [compressed file name] [file/directory name before compression]
-C: the package file of pai.tar, required
-V: displays details.
-F: Specifies the compressed file name, which is mandatory.
-Z: compress the package at the same time.
E.g. tar-cvfz dir1.tar.gz dir1 # package dir and compress it into a file
[Note-this one-step packaging and compression is not supported by all UNIX systems!]
At this time: 1) package: tar-cf newdir.tar newdir
2) compression: gzip newdir.tar # or use a connector.
4. decompress the package
Tar [Option]:
-X unpack the .tar File
-V: Show Details
-F: Specifies the file to be decompressed.
-Z Decompression
E.g. tar-zxf newdir4.tar.gz
Step-by-Step gunzip newdir.tar.gz
Tar-xvf newdir.tar
----------.Zip ----------
5. zip:/usr/bin/zip
Windows and linuxare only generic. If the file size is not large, we recommend that you use. Zip.
Format: zip [Option-r] [compressed file name] [compressed file/directory name]
E.g. zip services.zip/etc/services compressed file
Zip-r newdir.zip test compressed directory
Two major defects of gzip compensated by zip: 1) Keep the source file
2) directory can be compressed
6. unzip/usr/bin/unzip
Example: unzip newdir.zip # retain the original file
----------.Bz2 ----------
7. bzip2/usr/bin/bzip2
The compressed version is quite surprising than the upgraded version of gzip. however, it cannot be used with the compressed file name .bz2. Of course, it can also be used with tar.
Format: bzip2 option [-k] [file name] # Add-k to keep the source file, otherwise it will be the same as zip
8. bunzip2
You can use-k to retain source compressed files.