Summary of decompressing and compressing commands such as tar.gz, tar, bz2, and zip in Linux

Source: Internet
Author: User
Tags uncompress

The most common packaging in LinuxProgramThe package we use the tarprogram is often called a tarpackage, and the command of the tarpackage file is always ended with .tar. After the tar package is generated, you can use other programs
Line compression, so first let's talk about the basic usage of the tar command:
There are many options for the tar command (which can be viewed using man TAR), but there are several commonly used options. below
For example:
# Tar-CF all.tar *. jpg
This command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.
,-F specifies the package file name.
# Tar-RF all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
Meaning.
# Tar-UF all.tar logo.gif
This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.

# Tar-TF all.tar
This command is used to list all files in the all.tar package.-T is used to list objects.
# Tar-XF all.tar
This command is used to extract all files in the all.tar package.-X is used to unlock the file.
The above is the most basic usage of tar. To help you compress or decompress the package
File, tar provides a special feature. This means that tar can call other pressures while packaging or unpacking.
Program shrinking, such as calling gzip and Bzip2.
1) tar calls Gzip
Gzipis a program developed by gnuorganization. The file ending with .gz is the result of gzip compression. And Gzip
The relative decompression program is gunzip. Use the-Z parameter in tar to call gzip. The following is an example.
:
# Tar-CZF all.tar.gz *. jpg
This command is to compress all .jpg files into a tar package and use gzip to generate
The package name is all.tar.gz.
# Tar-xzf all.tar.gz
This command unlocks the generated package.
2) tar call Bzip2
Bzip2is a more powerful compression program. The file ending with .bz2 is the result of Bzip2 compression.
The decompress program relative to Bzip2 is bunzip2. Use the-J parameter in tar to call gzip. The following is an example.
Note:
# Tar-CJF all.tar.bz2 *. jpg
This command is to compress all .jpg files into a tar package and use Bzip2 to generate
Bzip2compressed package named all.tar.bz2
# Tar-xjf all.tar.bz2
This command unlocks the generated package.
3) tar call Compress
Compress is also a compression program, but it seems that people who use compress are not as good as those who use gzip and Bzip2.
More .. The file ending with Z is the result of Bzip2 compression. The decompress program relative to compress is uncompress.
. Use the-Z parameter in tar to call compress. The following is an example:
# Tar-CZF all.tar. z *. jpg
This command is to compress all .jpg files into a tar package and generate
An uncompress compressed package named all.tar. Z
# Tar-xzf all.tar. Z
This command is used to unbind the generated package.

with the above knowledge, you should be able to uncompress multiple types of files. The following is a summary of the compressed files in the TAR series
:
1. files ending with .tar
tar-XF all.tar
2. files ending with .gz
gzip-D all.gz
gunzip all.gz
3. files ending with .tgzor .tar.gz
tar-xzf all.tar.gz
tar-xzf all. tgz
4)for files ending with .bz2
Bzip2-D all.bz2
bunzip2 all.bz2
5)for files ending with tar.bz2
tar-xjf all.tar.bz2
6) for. file ending with z
uncompress all. z
72.16.tar. file ending with z
tar-xzf all.tar. z

In addition, Linux has corresponding methods to decompress the compressed file. zipand. rar under Windows.
1. For. Zip,
the zip and unzip programs are provided in Linux. Zip is a compression program, unzip is a decompression program. Their Parameters
have many options. Here we will only give a brief introduction and give examples to illustrate their usage:
# zip all.zip *. JPG
This command compresses all .jpg files into a zip package
# unzip all.zip
This command decompress all files in all.zip
2. For .rar
to process .rar files under linux, you need to install RAR for Linux, which can be downloaded from the Internet, but remember that RAR for Linux is not free of charge. You can download rarfor Linux 3.2 from http://www.rarsoft.com/download.htm.
0, and then install:
# tar-xzpvf rarlinux-3.2.0.tar.gz
# cd RAR
# Make
so that the installation is complete, after installation, there will be the RAR and unrar programs. rar is Unrar is the decompression program. They have many Parameter options. Here we will only give a brief introduction and give examples to illustrate their usage:

# Rar a all *. jpg
This command is to compress all. jpg files into a rarpackage named all.rar. this program will
The extension name is automatically appended to the package name.
# Unrar e all.rar
This command is to extract all files from all.rar.
By now, we have introduced 10 types of compressed files, tar, Gzip, gunzip, Bzip2, bunzip2, compress, uncompress, Zookeeper,. zw..tar.zw..zipw..rar, in Linux.
In the future, you do not need to worry about downloading a software without knowing how to solve it in Linux. In addition, the above method is basically effective for Unix.
This article introduces the compressed files tar, Gzip, gunzip, Bzip2, bunzip2, compress, uncompress, zip, Zookeeper,. Z,. tar.zw..zipw.rar in Linux.
Operation.

Supplement

Tar

-C: Create a compressed file
-X: Extract
-T: View content
-R: append an object to the end of the compressed archive object
-U: update files in the original compressed package

These five are independent commands, one of which must be used for compression and decompression. They can be used with other commands, but only one of them can be used. The following parameters are optional when files are compressed or decompressed as needed.

-Z: With the gzip attribute
-J: With the bz2 attribute
-Z: With the compress attribute
-V: displays all processes.
-O: unbind the file to the standard output

The following parameter-F is required
-F: Specifies the file name. This parameter is the last parameter and can only be followed by the file name.
# The Tar-CF all.tar * .jpg command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-F specifies the package file name.
# tar-RF all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
# tar-UF all.tar logo.gif
this command is used to update the logo.gif file in tarpackall.tar.tar.-u indicates the meaning of the update file.
# tar-TF all.tar
this command is used to list all files in the all.tar package, -T indicates listing objects.
# tar-XF all.tar
this command is used to extract all objects in the all.tar package, -X indicates unzipping
tar-CVF jpg.tar *. JPG // pack all JPG files in the Directory into tar.jpg
tar-CZF jpg.tar.gz *. JPG // folder
tar-CJF jpg.tar.bz2 *. JPG // folder
tar-CZF jpg.tar. z *. JPG // response. z
rar a jpg.rar *. for JPG/RAR compression, download RAR for Linux
zip jpg.zip *. for JPG/zip compression, You need to download zip for Linux

Extract
Tar-xvf file.tar // decompress the tar package
Tar-xzvf file.tar.gz // decompress tar.gz
Tar-xjvf file.tar.bz2 // unzip tar.bz2
Tar-xzvf file.tar. Z // extract tar. Z
Unrar e file.rar // extract RAR
Unzip file.zip // decompress the ZIP file

Summary
1. Decompress *. tar with tar-xvf
2. Use gzip-D or gunzip to decompress *. GZ
3. Use tar-xzf to decompress * .tar.gz and *. tgz.
4. Use Bzip2-D for *. bz2 or use bunzip2 for decompression.
5. Use tar-xjf to decompress * .tar.bz2
6. Use uncompress to decompress *. Z
7. Decompress *. Tar. Z with tar-xzf
8. Extract files using unrar E for *. rar
9. Decompress *. Zip with unzip

Detailed source reference: http://www.jb51.net/LINUXjishu/43356.html

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.