"Linux Basics" compression and decompression

Source: Internet
Author: User
Tags bz2 pack rar rar extension uncompress

Types of compression and decompression files commonly used by Linux:. tar,.gz,. tar.gz,.bz2,. tar.bz2,.z,. Tar. Z,.zip,.rar and so on.

Linux commonly used compression and decompression commands are: Tar,gzip, GUNZIP,BZIP2, bunzip2,compress, uncompress, Zip, Unzip,rar, Unrar and so on.

Summary:

Compression:

TAR–CVF Jpg.tar *.jpg       //package all JPG files in the directory into Jpg.tar tar–czf jpg.tar.gz *.jpg    //package all JPG files in the directory into Jpg.tar and use gzip Compress, generate a compressed package named jpg.tar.gz TAR–CJF jpg.tar.bz2 *.jpg   //To package all JPG files in the directory into Jpg.tar, and use bzip2 compression to generate a voltage named jpg.tar.bz2 Shrink Pack tar–czf jpg.tar.z *.jpg     //pack all JPG files in the directory into Jpg.tar, and compress them in compress to generate a compressed package named Jpg.tar.z rar a Jpg.rar *.jpg
   //rar format compression requires first download of RAR for Linux zip jpg.zip *.jpg            //Zip format compression

Extract:

TAR–XVF File.tar         //Unpacking the TAR package TAR-XZVF file.tar.gz     //decompression tar.gz TAR-XJVF file.tar.bz2    //decompression tar.bz2 Tar–xzv F File.tar.z      //Unzip tar. Z unrar e file.rar          //decompression RAR unzip File.zip            

Summary:

1, *.tar with TAR–XVF decompression 2, *.gz with gzip-d or Gunzip decompression 3, *.tar.gz and *.tgz with TAR–XZF decompression 4, *.bz2 with bzip2-d or BUNZIP2 decompression 5, *.tar.b Z2 with TAR–XJF decompression 6, *. Z Extract 7, *.tar with Uncompress. Z with TAR–XZF decompression 8, *.rar with Unrar e decompression 9, *.zip with unzip decompression

1. Compress 1.1 package into a. tar file:

The most common packaging commands are tar, which we often refer to as tar packages, and the tar package files usually end in. Tar. Once the tar package is generated, it can be compressed with other programs.

Instance:

The following command is to make all. jpg files into a package named All.tar. -C is the file name that represents the generation of a new package,-f specifies the package.

# TAR-CF All.tar *.jpg

The following command adds all. gif files to the All.tar package, and-R is meant to add the file.

# TAR-RF All.tar *.gif

The following command is to update the original tar package All.tar in the logo.gif file,-U is to indicate the meaning of the update file.

# Tar-uf All.tar logo.gif

The following command lists all the files in the All.tar package, and-T is the meaning of the list file.

# TAR-TF All.tar

Tar provides a special feature to facilitate the user's ability to compress or decompress a file while unpacking the package. This is what tar can call other compression programs while packaging or unpacking, such as calling Gzip, bzip2, and so on.

Tar parameter:

These five are stand-alone commands, which use one of the compression decompression, and can be used with other commands but only one.

-C: Build Compressed Archives-x: Unzip-T: View Content-r: Append files to the end of the compressed archive-u: Update the files in the original compressed package

The following parameters are optional when compressing or extracting files as needed.

The following parameter-F is required:

-F: Use the file name, Remember, this parameter is the last parameter, only after the file name

  

1.2 compressing into. tar.gz files

This command is to make all. jpg files into a tar package and compress them in gzip to generate a gzip-compressed package named all.tar.gz.

# TAR-CZF all.tar.gz *.jpg//tar using the-Z parameter to invoke gzip

Gzip is a compression program developed by the GNU organization, and the. Gz end file is the result of gzip compression. The decompression procedure relative to Gzip is gunzip. Use the-Z parameter in tar to invoke gzip.

1.3 Compression into. tar.bz2 file

This command is to make all. jpg files into a tar package and compress them with bzip2 to generate a bzip2 compressed package named ALL.TAR.BZ2.

# TAR-CJF all.tar.bz2 *.jpg//tar use-j this parameter to invoke BZIP2

1.4 compressed into. Tar. Z file

This command is to make all. jpg files into a tar package and compress them with compress to generate a compress compressed package named All.tar.z.

# TAR-CZF All.tar.z *.jpg//tar using the-Z parameter to invoke compress

1.5 compress into a. zip file
# Zip All.zip *.jpg//compress all. jpg files into a zip package
# zip-r Filename.zip filename
# zip-r Filename.zip file1 file2 file3/usr/work/school//compress the contents of File1, File2, File3, and/usr/work/school directories (assuming this directory exists). and put it in the Filename.zip file.

Linux provides a zip and unzip program, ZIP is a compression program, unzip is the decompression program.

1.6 compress into a. rar file

To process the. rar file under Linux, you need to install RAR for Linux. : http://www.rarsoft.com/download.htm, install after download.

# TAR-XZPVF rarlinux-x64-5.6. b5.tar.gz# cd rar # make

This installs well, after installation has RAR and unrar these two programs, RAR is the compression program, Unrar is the decompression program.

This command compresses all. jpg files into a RAR package named All.rar, which will automatically append the. rar extension to the package name.

# rar a All *.jpg

2. Unzip the file at the end of the 2.1 decompression. Tar:
# TAR-XF All.tar//-x is to untie the meaning,-f specifies the file name of the package

2.2 Unzip. tar.gz or . tgzEnd of File:
# TAR-XZF all.tar.gz//-x is the meaning of the undo, using the-Z parameter in tar to invoke the file name of the GUNZIP,-F specified package
# TAR-XZF All.tgz
extract the file ending with. GZ:
Gunzip all.gz

2.3 Extracting. tar.bz2 files
# TAR-XJF all.tar.bz2//-x is the meaning of the undo, using the-j parameter in tar to invoke the file name of the specified package bunzip2,-f
Unzip. bz2 End of File:
BUNZIP2 all.

2.4 Unzip. Tar. Z file
# TAR-XZF All.tar.z//-x is the meaning of the undo, using the-Z parameter in tar to invoke the file name of the UNCOMPRESS,-F specified package
Extract. Z file:
Uncompress all. Z

2.5 extracting the. zip file
Unzip All.zip

2.6 Extracting. rar files

To process the. rar file under Linux, you need to install RAR for Linux. See section 1.6 for details.

# Unrar E All.rar

References

Linux tar.gz, tar, bz2, zip and other decompression, compression command detailed




"Linux Basics" compression and decompression

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.