Linux packaging, compression, decompression summary __linux

Source: Internet
Author: User
Tags bz2 rar rar extension unpack uncompress
First of all, attach Linux under the various suffix format Compression decompression command, if you do not want to understand why the reason can run out.

. tar
Unpack: Tar xvf Filename.tar
Packing: Tar cvf filename.tar dirname
(Note: Tar is packed, not compressed.) )
Advanced packaging use, excluding several directories, specifying the package path.
Tar--exclude=var/www/ff-bb.cn/download--exclude=var/www/ff-bb.cn/download2 CFZ hosteguide.com.tar.gz/var/www/ hosteguide.com/
Note the exclusion directory after the--exclude cannot be taken/, otherwise it will not work. Tar is described in detail below.
———————————————
. gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName

. tar.gz and. tgz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz dirname
———————————————
. bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName

. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 dirname
———————————————
. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown

. tar.bz
Decompression: Tar jxvf FileName.tar.bz
Compression: Unknown
———————————————
. Z
Decompression: uncompress filename.z
Compression: Compress FileName
. Tar. Z

Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z dirname
———————————————
. zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip dirname
———————————————
. rar
Decompression: rar x Filename.rar
Compression: rar a filename.rar dirname
———————————————
. Lha
Decompression: Lha-e Filename.lha
Compression: Lha-a Filename.lha FileName
———————————————

The following is a detailed description:
First, it's clear that the compressed package we see is divided into two types:
1, packaging the scattered files merged into a file, which in storage, transmission are extremely advantageous. (such as a source code has thousands of source files, in the replication, network delivery process requires each file to be launched separately.) You can copy folders of the same size and scattered files compare time
2, compression is through a variety of algorithms to reduce the total size of packaged files, reduce the size of the file has two obvious benefits, one is to reduce storage space, the second is the transmission of files over the network, can reduce the transmission time.

Observe the various compression-decompression formats above to find patterns:
If there is a. gz format of the compressed package, there are also the. tar.gz format of the first packaged compressed package, other similar format. The latter we have seen more, of course, more advantages.

The packages that are used in the TAR program are often referred to as tar packets, and the TAR package file commands are usually terminated with. Tar. After the tar package is generated, you can use other programs to enter
Line is compressed, so let's start with the basic usage of the TAR command:
There are many options for the tar command (which can be viewed with man tar), but there are a few options that are commonly used, and here are some examples:
# TAR-CF All.tar *.jpg
This command is to make all. jpg files into a package named All.tar. -C indicates the creation of a new package,-f Specifies the file name of the package.
# TAR-RF All.tar *.gif
This command adds all the. gif files to the All.tar package. -R means to add a file.
# Tar-uf All.tar logo.gif
This command updates the logo.gif file in the original tar package All.tar, and-U is the meaning of the update file.

# TAR-TF All.tar
This command lists all the files in the All.tar package----------T is the list of files
# TAR-XF All.tar
This command is to solve all the files in the All.tar package------X is the meaning of the undo
The above is the most basic use of tar. In order to facilitate the packaging and unpacking of the user can compress or extract files, tar provides a special function. This is where tar can call other presses while packing or unpack.
Shrink programs, such as calling Gzip, bzip2, and so on.
1) Tar call gzip
Gzip is a compression program developed by the GNU organization, the file at the end of GZ is the result of gzip compression. The decompression program relative to Gzip is gunzip. Use the-Z parameter in tar to invoke gzip. Here are some examples to illustrate

# TAR-CZF all.tar.gz *.jpg
This command is to make all. jpg files into a tar package and use gzip compression to generate a gzip-compressed package named all.tar.gz
# TAR-XZF All.tar.gz
This command is to untie the packets generated above.
2) Tar call bzip2
BZIP2 is a more compressed program,. bz2 end of the file is the result of bzip2 compression. The bzip2 relative to the decompression program is BUNZIP2. Use-j this parameter in tar to invoke gzip. Here's an example.
Explain:
# TAR-CJF all.tar.bz2 *.jpg
The command is to make all. jpg files into a tar package, and use bzip2 compression to generate a BZIP2 compressed package named all.tar.bz2
# TAR-XJF ALL.TAR.BZ2
This command is to untie the packets generated above.
3) Tar call compress
Compress is also a compression program, but it seems that people who use compress are not as good as gzip and bzip2. The file at the end of Z is the result of bzip2 compression. The decompression program relative to compress is uncompress
。 Use the-Z parameter in tar to invoke compress. Here are a few examples to illustrate:
# TAR-CZF All.tar.z *.jpg
The command is to make all. jpg files into a tar package, and use compress compression to generate a uncompress compressed package named All.tar.z
# TAR-XZF All.tar.z
This command is to unlock the resulting package.


With the above knowledge, you should be able to unlock a variety of compressed files, the following for the TAR series of compressed files to make a summary:
1 for. Tar End of File
TAR-XF All.tar
2 for. GZ End of File
Gzip-d all.gz
Gunzip all.gz
3. Documents ending with. tgz or. tar.gz
Tar-xzf all.tar.gz
Tar-xzf all.tgz
4 for. bz2 End of File
Bzip2-d all.bz2
BUNZIP2 all.bz2
5) For tar.bz2 end of file
TAR-XJF all.tar.bz2
6) for. File at the end of Z
Uncompress all. Z
7 for. Tar.z End of File
Tar-xzf All.tar.z

In addition to the common compressed files under Windows. zip and. Rar,linux also have a corresponding way to extract them:
1) for. zip
Linux provides a zip and unzip program, ZIP is a compression program, unzip is the decompression program. They have a lot of parameter options, here is a simple introduction, still give examples of its use:
# Zip All.zip *.jpg
This command compresses all. jpg files into a zip package
# Unzip All.zip
This command is to extract all the files in the All.zip
2) for. rar
To process A. rar file under Linux, you need to install RAR for Linux, which can be downloaded from the Web, but remember that RAR for Linux is not free; download rarfor from http://www.rarsoft.com/download.htm Linux 3.2.
0, and then install:
# TAR-XZPVF Rarlinux-3.2.0.tar.gz
# CD RAR
# make
This is installed, installed after the RAR and unrar these two programs, RAR is a compression program, Unrar is the decompression program. They have a lot of parameter options, here is a simple introduction, still give examples of its use:

# rar a All *.jpg
This command compresses all. jpg files into a RAR package named All.rar, which automatically attaches the. rar extension to the package name.
# Unrar E All.rar
This command is to extract all the files in the All.rar
In this context, we have introduced Linux under the TAR, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, RAR, Unrar and other programs, you should have been able to use them for. Tar

,. GZ,. tar.gz,. tgz,. bz2,. tar.bz2,. Z,. Tar. Z,. zip,. rar, these 10 compressed files for decompression, you should not need to download a software and do not know how to untie under Linux and worry. And the above method is also basically effective for UNIX.
This article describes the programs in the Linux compression program tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, RAR, Unrar, and how to use them for. Tar,. GZ,. tar.gz, tgz,. bz2,. tar.bz2,. Z. Tar. Z,. zip,. rar, these 10 compressed files to operate.






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.