Linux Compression Packaging Summary

Source: Internet
Author: User
Tags bz2

1 Compression Packaging Introduction

The compressed files under Linux have

Linux. Zip,.gz,.bz2,.xz,.tar.gz,.tar.bz2,.tar.xz

2 gzip Compression Tool

Gzip Cannot compress directory

Small test:

Compression pre-work: [[EMAIL PROTECTED] TMP]# MKDIR D6Z [[EMAIL PROTECTED] TMP]# CD  d6z/[[email protected] d6z]# find /etc/ -type f -name  "*conf"  -exec cat {} >> lf.txt \; (Find/etc/*conf configuration file, view and append content to lf.txt [email  protected] d6z]# du -sh lf.txt (view size of Lf.txt) 296klf.txt[[email protected]  d6z]# gzip lf.txt  (compressed file,gzip  directly followed by file) [[Email protected] d6z]# du -sh  lf.txt.gz308Klf.txt.gz[[email protected] d6z]# gzip -d lf.txt.gz  (Unzip, gzip  -d ) =gunzip lf.txt.gz [[email protected] d6z]# file lf.txt.gz  ( file  view file type) [[email protected] d6z]# zcat lf.txt.gz  (view the contents of the compressed file) [email  protected] d6z]# gzip -c lf.txt > /tmp/lf.txt.gz  (the original file exists when compressing) [[email  Protected] d6z]# gunZip -c /tmp/lf.txt.gz > /tmp/d6z/chy.txt  =gzip -d /tmp/lf.txt.gz  >/tmp/d6z/chy.txt  (file exists when uncompressed) [[email protected] d6z]# wc -l lf.txt  Chy.txt (Compare the size of the existing two files)   30864 lf.txt  30864 chy.txt  61728  total usage

3 bzip2 Compression Tool

BZIP2 Cannot compress directory

[email protected] d6z]# yum install-y bzip2 [[email protected] d6z]# bzip2 lf.txt (bzip2 compressed file) [[email protected] d6z]# BZ ip2-d lf.txt.bz2 = Bunzip lf.txt.bz2 (decompression) [[email protected] d6z]# bzip2-c lf.txt >/tmp/lf.txt.bz2 (the original file exists when the file is compressed bzip2 ) [[email protected] d6z]# bunzip2-c/tmp/lf.txt.bz2 >/tmp/d6z/lll.txt (original file exists when bzip2 uncompressed) [[email protected] d6z]# Bzcat CHY.TXT.BZ2 viewing the contents of a compressed file

4 XZ Compression Tool

Cannot compress directory

[[email protected] d6z]# XZ chy.txt (compressed file)) [[email protected] d6z]# xz-d chy.txt.xz = unxz chy.txt.xz (uncompressed) xz-c CHY.TXT&G T /tmp/chy.txt.xz xz-d-c/tmp/chy.txt.xz > 1.txt.new3 [[email protected] d6z]# xzcat CHY.TXT.XZ View Compressed files

5 Zip compression Tool

Zip supports compressed directory Zip command can be used to extract files, or file packaging operations. Zip is a widely used compression program that, when compressed, will generate additional compressed files with a ". zip" extension.

[[email protected] d6z]# yum install -y zip   (Install Zip package) [[email  Protected] d6z]# zip lf.txt.zip chy.txt (zip  followed by the compressed file name   Last in the file that needs to be compressed) [[email  Protected] d6z]# zip -r chy.zip aminglinux lll.txt (zip  followed by-r  is a compressed directory  zip -r  after compressing the finished name followed by the compressed directory and the directory you want to compress (below is the zip parameter)-A: Adjust the executable automatic decompression file;-b< working directory;: Specifies the directory where files are temporarily stored ;-C: annotate each compressed file;-D: Deletes the specified file from the compressed file;-D: The directory name is not established within the compressed file; the effect of this parameter is similar to specifying the "-u" parameter, but not only updates the existing file, if some files do not exist in the compressed file originally. The use of this parameter will be added to the compressed file, F: Try to repair the corrupted compressed file,-G: Compress the file after the existing compressed file, rather than create a new compressed file;-H: Online help;-i< template style;: Compress only eligible files -j: Save only the file name and its contents without any directory name;-j: Remove unnecessary data from the compressed file;-K: File name in MS-DOS compatible format;-L: When compressing a file, replace the LF character with the LF+CR character;-ll: When compressing the file, lf+ The CP character is replaced by the LF character;-L: Displays the copyright information;-M: The file is compressed and added to the compressed file, delete the original file, that is, to move the file into a compressed file;-n< string;: Do not compress files with a specific tail string ;-O: To compress files with the most recent change in time, the change time of the compressed file is set to the same as the file;-Q: Does not show the instruction execution process;-r: Recursively handles all files and subdirectories under the specified directory;-s: Contains system and hidden files;-t< date Time : Set the date of the compressed file to the specified date;-T: Check that each file in the backup file is correct;-u: Replace the newer file in the compressed file;-V: Shows the instruction execution process or the explicit-V: Save the file attributes of the VMS operating system;-W: In the file name, if the version number, this parameter is only valid under the VMS operating system;-x< template style;: Exclude files that meet the criteria when compressing;-X: Do not save additional file attributes; Instead of the file that the link points to, this parameter is valid only on systems such as UNIX;-Z: Add comments to the compressed file;-$: Saves the volume book name of the disk on which the first compressed file is located;-< compression efficiency;: Compression efficiency is a value between 1~9.

Unzip command

The unzip command is used to decompress the ". Zip" compression package that is compressed by the zip command. Syntax: Unzip (options) (parameters) [[email protected] d6z]# Yum install-y unzip (install unzip command) [[email protected] d6z]# unzip-d/tmp/aminglinux DDD.ZIP Specifies that the unzip option is extracted to another directory as follows-C: Displays the extracted results to the screen and converts the characters appropriately;-F: Updates the existing file;-L: Displays the files contained within the compressed file;-P: Similar to the-c parameter, the extracted results are displayed on the screen. It does not perform any conversions;-T: Checks that the compressed file is correct;-U: Similar to the-f parameter, but other files in the compressed file are extracted to the directory in addition to updating the existing file;-V: Displays detailed information when executed;-Z: Show only notes text for compressed files ;-A: Make necessary character conversions for text files;-B: Do not convert text files;-c: File names in compressed files are case-sensitive;-j: Do not handle directory paths in compressed files;-L: Change all file names in compressed files to lowercase ;-M: Send the output to more program processing;-N: Do not overwrite the original file when extracting;-O: Do not ask the user first, unzip after the implementation of the original file;-p< password;: Use the zip password option;-Q: Do not display any information when executing ;-S: Converts white space characters in file names to baseline characters;-V: Preserves file version information for VMS;-x: uid/gid;-d< directory at the same time when extracting the file;: Specifies the directory to be stored after extracting the file;-x< file > : Specifies which files in the. zip archive are not processed;-z:unzip-z equals the execution of the zipinfo instruction.

6 Tar Packaging tools

The TAR command creates archives for Linux files and directories. With tar, you can create files (backup files) for a specific file, or you can change files in the file or add new files to the file. Tar was originally used to create archives on tape, and now users can create files on any device. With the tar command, you can package a whole bunch of files and directories into a single file, which is useful for backing up files or combining several files into one file for easy network transmission.

Many of the compression programs in Linux can only be compressed for one file, so when you want to compress a lot of files, you have to first make a package (tar command) of this large number of files, and then compress the program (gzip bzip2 command).

[[email protected] d6z]# TAR-CVF Aminglinux.tar aminglinux (package file tar followed by C is create V is visualized, F is followed by the name of the package) [[email protected] d6z]# tar -XVF Aminglinux.tar (-X is unpacking) [[email protected] d6z]# TAR-CVF chylinux.tar--exclude "*". txt chylinux (--exclude is in addition to a package of [Email protected] d6z]# TAR-TF Aminglinux.tar (tar can view the contents of the packaged file)

7 Packing and compressing

[[email protected] d6z]# tar -zcvf  chylinux.tar.gz chylinux  (packaged and compressed into gzip format) [[email protected] d6z]# tar -cjvf  chylinux.tar.bz2 chylinux  (packaged and compressed into bz2 format) [[email protected] d6z]# tar -cjvf  Chylinux.tar.xz chylinux (packaged into XZ compression mode) [[email protected] d6z]# tar -tf  chylinux.tar.xz  (view packaged content) 

hope to see the children's shoes a lot of advice, thank you! 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0063.gif "alt=" J_0063.gif "style=" Padding:0px;margin : 0px;vertical-align:top;border:none; "/>650) this.width=650;" src= "Http://img.baidu.com/hi/jx2/j_0063.gif" alt= "J_0063.gif" style= "padding:0px;margin:0px;vertical-align:top;border:none;"/>

Linux Compression Packaging Summary

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.