"Linux Learning Notes" chapter 6th Linux file compression and packaging

Source: Internet
Author: User
Tags bz2 unpack

6.1 Compression Packaging Introduction
Windows compression:. rar,.zip,.7z
Linux compression:. zip,.gz,.bz2,.xz,.tar.gz,.tar.bz2,.tar.xz

6.2gzip Compression Tool
gzip filename Compressed file , format GZ, compressed after source file disappears.
gzip-d filename.gz unzip the file.
gzip-[1-9] filename.gz Compressed files when you specify the compression level, 1 lightest, 9 most ruthless.
gunzip filename.gz can also be decompressed.
File FILENAME to view information about the files.
zcat filename.gz can view the contents of a compressed file.
gzip-c FILENAME >/dirname/filename.gz , plus- c option, preserves the source file and compresses the file to the specified path.
gzip-d-C filename.gz >/dirname/filename Unzip the compressed file to the specified location.
gzip cannot compress the directory.

6.3BZIP2 Compression Tool
bzip2, compression is more aggressive than gzip, and the format is bz2. Install the BZIP2 package first (yum install-y bzip2)
The usage of bzip2 is consistent with the gzip usage, with the default compression level of 9, with the- C option, preserving the source file and specifying the destination file path, while bzip2-d decompression is also associated with BUNZIP2 equivalent,bzcat View Compressed file contents
bzip2 also cannot compress the directory.

6.4XZ Compression Tool
XZ, compression is more ruthless than bzip2 , the format is XZ.
xz usage with gzip,bzip2 usage, default compression level of 6, plus- c option, preserve source file and specify destination file path while xz-d decompression is also equivalent to unxz ,xzcat View the contents of the compressed file.
XZ also cannot compress the directory.

6.5zip Compression Tool
Yum install-y zip installation zip package.
Zip compressed file. zip source file compressed file
zip-r compressed files. zip source file 1 [source file 2] ... The- r option, a compressible directory, is a directory that can exist in multiple source files.
After the zip is compressed, the source files are not deleted.
unzip compressed files. zip-d DIR Decompression (yum install-y unzip)-d option specifies the extract directory (cannot be specified to the decompression name, the specified decompression name will be recognized as a directory), if not specified, The default current directory.
zip cannot use commands to view the contents of a file.
unzip-l compressed file. zip to see a list of files in the compressed file.

6.6tar Packaging
TAR-CVF packaging files. Tar [--exclude filter file 1] [--exclude filter file 2] source file 1 [source file 2] ... Packaging files, directories, and so on.
Parameters:
- C package creation.
- v visualization.
- F followed by packaged files. Tar.
--exclude back and pack the files that need to be filtered out.

6.7 Packing and compressing
When packaging, you can add one of the following parameters to compress the package at the same time:
- Z supports gzip compression, and the compressed file format is saved as. tar.gz.
The -j supports bzip2 compression, and the compressed file format is saved as. tar.bz2.
-j supports XZ compression, and the compressed file format is saved as. Tarxz.
TAR-XVF package files. Tar unpack.
- x unpack the package.
If you pack compressed files, you need to add the corresponding compression parameters to decompress.
The tar package or unpacking will overwrite the existing source file directly without prompting.
TAR-TF packaging files. Tar view a list of files within a packaged file, including packing and compressing, can also be viewed.

"Linux Learning Notes" chapter 6th Linux file compression and packaging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.