3.4 Compression decompression command. gz. tar.gz. zip. bz2
1) Gzip Compress files only
The gzip command is used to compress the file, the English original is the GNU Zip, where the path/bin/gzip, the syntax format is:
gzip [file]
The compressed file format is. gz.
Note:
1 only files can be compressed
2 Do not retain the original document
?
2) Gunzip
Unzip gunzip [compressed file] or Gzip–d [compressed file]
3) Tar compressed files and directories
The tar command is used to package the directory , where the path is/bin/tar, in the syntax format:
Tar options [-ZCF] [file name after compression] [table of contents]
Where the-c option means packaging; the-v option indicates that details are displayed, the-F option specifies the file name, and the-Z option means that the package is compressed at the same time, and the compressed file format is. tar.gz or. tgz
TAR–ZCVF dir.tar.gz [file or directory to be compressed]
?
Note: file+ file: View file type directives
Type + directive: View instruction Type
?
4) Tar unzip files and directories
TAR-XZVF [Compressed file]
Where the-x option represents unpacking, the-V option indicates that details are displayed, the-F option indicates the specified decompression file, and the-Z option indicates decompression and is extracted to the current directory
5) Zip compressed files and directories
The Zip command is used to compress a file or directory , where the path is/usr/bin/zip, with the syntax in the following format:
Zip option [-r] [filename after compression] [file or directory]
Where the-r option represents a compressed directory, and the compressed file format is. zip.
. zip default Windows and Linux only common format
6) Unzip
The Unzip command is used to extract the. zip file , where the path is/usr/bin/unzip, with the syntax in the following format:
Unzip [compressed file]
?
7) Bzip2: can only compress files
Bzip2 is an upgraded version of Gzip and is also used to compress files , where the path is/USR/BIN/BZIP2, with the syntax in the following format:
BZIP2 option [-K] [file]
Where the -K option produces a compressed file after preserving the source file. The compressed file format is. bz2.
Use the tar command to save the directory as a. bz2 file in the following format:
Tar options [-CJVF] [file name after compression] [directory]
Where the-J option means that the compression is a. tar.bz2 file .
?
8) BUNZIP2
The bunzip2 command is used to decompress the. bz2 file , where the path is/USR/BIN/BUNZIP2, with the syntax format:
BUNZIP2 option [-K] [compressed file]
Where- k indicates that the source file is preserved after decompression .
The tar command can also be used to decompress. bz2 files in the format:
Tar options [-XJVF] [Compressed Files]
4_linux_ file compression and decompression instructions