Linux packaging and decompression commands, linux packaging and decompression
In linux, the following common compression formats are available: .zip、.gz).bz22.16.tar.gz#.tar.bz2.
1. zip: This format is common in linux and windows. The package format is: (zip compressed file name source file), (zip-r compressed file name source directory ).
Zip compression retains the source file. Decompress the file in the format of unzip. Decompress the package and keep the original compressed file.
2. gzip: the package format is: (gzip source file). This method compresses the file and the source file disappears (gzip-c source File> compressed file). This method retains the source file, for example, gzip-c abc> abc.gz. (Gzip-r directory) compress all the sub-files in the directory, but cannot compress the directory .? Decompression format: (gzip-d compressed file), (gunzip compressed file), (gunzip-r compressed directory ).
3. bz2: the package format is: (bzip2 source file is compressed into. bz2 format, and the source file is not retained. (Bzip2-k source file) the source file is retained after compression. Note: The bzip2 command cannot compress directories. Decompression format: (bzip2-d compressed file),-k can retain the compressed file, (bunzip2 compressed file),-k can retain the compressed file.
42.16.tar.gz(.tar.bz2): This format is actually first packaged into a tar, and then packaged into a corresponding format using the above command, in order to solve the problem that some commands cannot compress directories. Package it into tar command: (tar-cvf package file name or directory name source file or source directory),-c: Package,-v: Display process,-f: specify the name of the packaged file or directory, for example: (tar-cvf abc.tar abc) extract the tar command: (tar-xvf package file name or directory name),-x: unpack, example: (tar-xvf abc.tar ).
Command:
.Tar.gz: directly package it into the .tar.gz :( tar-zcvf compressed package name .tar.gz source file),-z: compressed into .tar.gz format. Directly decompress .tar.gz :( tar-zxvf compressed package name .tar.gz),-x: decompressed. tar.gz format.
.Tar.bz2: directly package .tar.bz2 :( tar-jcvf compressed package name .tar.bz2 source file),-j: compressed into .tar.bz2 format. Directly decompress .tar.bz2 :( tar-jxvf compressed package name .tar.bz2),-x: decompressed .tar.bz2 format.