Linux file compression and Packaging commands (learn notes) __linux

Source: Internet
Author: User
Tags bz2 gz file unpack

1. File Compression

File compression commands are divided into:
gzip : Compress files
gunzip : Extract Files
gzip-d: can also be used to extract files
bzip2 : Also compressed file
bunzip2 : Extract bzip2 Compressed files

Examples of the use of commands:
gzip Install.log : (Compress install.log files under current directory)
gunzip install.log.gz: (extract install.log.gz file)
gzip-d install.log.gz: (extract install.log.gz file)
bzip2 install.log : (Compress install.log files under current directory)
bunzip2 install.log.bz2: (extract install.log.bz2 file)

Of course, the file compression can also be extracted into a different file directory, "-C" parameter (refers to the contents of the file to be extracted to which file) for example:
gunzip install.log.gz-c/etc/doc (Here I will install.log.gz compressed files to be extracted to the ETC directory under the doc file) with bzip2 compressed file is the same, just add a-c parameter, and then specify the decompression path.

2. File Packaging

Package commands are divided into:
tar cvf: File packaging
tar rvf: Append files
tar xvf: Unpack files

There is the package after the file is compressed, the command is:
tar Cvfz(packaged and compressed, +z is an indication of gzip compression)
tar xvfz(unpack)
tar cvfj(packaged and compressed, +J is a compression that represents bzip2)
tar xvfj(unpack)

Examples of command usage:
# tar Cvf/tmp/root.tar . (Create a packaged file named Root.tar in the TMP directory, and then package all the files in the TMP directory, "." refers to all files)
# tar rvf/tmp/root.tar/etc/passwd (Add the passwd file in the ETC directory to the Root.tar package file)
# tar Xvf/tmp/root.tar (Unlock the Root.tar package in the TMP directory)
# tar cvfz/tmp/root.tar.gz . (Create a packaged compressed file named root.tar.gz in the TMP directory, and then package all files in the TMP directory and compress them)
# tar cvfj/tmp/root.tar.bz2 . (Create a packaged compressed file named ROOT.TAR.BZ2 in the TMP directory, and then package all files in the TMP directory and compress them)
Unpack the package only need to change CVF to XVF on line, also can add parameter-C to extract the compressed package to the specified directory, with the above said compressed file decompression same

Related Article

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.