This article describes the programs that are compressed under Linux, such as 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 10 compressed files, and finally describes the meaning of the parameters when using the tar command, English explanations, and common options combinations.
One must first understand two concepts: packaging and compression.
Packaging refers to a lot of files or directories into a total file, compression is a large file through some compression algorithm into a small file. Why should we differentiate between these two concepts? In fact, this is because many of the compression programs in Linux can only be compressed for a single file, so when you want to compress a lot of files, you have to use another of its tools to make the whole heap of files first into a package, and then the original compression program compression.
Two kinds of packaging and compression introduction
The most common packaging program under Linux is tar, which is often referred to as the TAR package, and the tar package file commands are usually terminated with. Tar. After the tar package is generated, it can be compressed with other programs, so the basic usage of the tar command is first spoken:
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, as illustrated below:
# TAR-CF All.tar *.jpg
This 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-RF All.tar *.gif
This command adds all the. gif files to the All.tar package. -R is meant to increase the file.
# Tar-uf All.tar logo.gif
This 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-TF All.tar
This command is to list all the files in the All.tar package,-T is to list the meaning of the file
# TAR-XF All.tar
This command is to solve all the files in the All.tar package,-X is the most basic use of 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.
1) Tar call gzip
Gzip is a compression program developed by the GNU organization, and the. Gz end file is the result of gzip compression. With gzip
The relative decompression procedure is gunzip. Use the-Z parameter in tar to invoke gzip. Here's an example:
# TAR-CZF all.tar.gz *.jpg
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-XZF All.tar.gz
This command unlocks the package generated above.
2) Tar call bzip2
Bzip2 is a more compressible compression program, and the. bz2 end of the file is the result of bzip2 compression. The decompression procedure relative to bzip2 is bunzip2. Use the-j parameter in tar to invoke gzip. Here's an example:
# TAR-CJF all.tar.bz2 *.jpg
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-XJF ALL.TAR.BZ2
This command unlocks the package 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 compress compression. The decompression procedure relative to compress is uncompress. Use the-Z parameter in tar to invoke compress. Here's an example:
# TAR-CZF All.tar.z *.jpg
This command is to make all. jpg files into a tar package and compress them with compress to generate
A uncompress compressed package with the package named All.tar.z
# TAR-XZF All.tar.z
This command is to solve the above-generated package with the above knowledge, you should be able to solve a variety of compressed files, the following for the TAR series of compressed files to make a summary:
1) for files ending in. tar
TAR-XF All.tar
2) for files ending in. gz
Gzip-d all.gz
Gunzip all.gz
3) for files ending with. tgz or. tar.gz
Tar-xzf all.tar.gz
Tar-xzf all.tgz
4) files ending with. bz2
Bzip2-d all.bz2
BUNZIP2 all.bz2
5) For tar.bz2 end of file
TAR-XJF all.tar.bz2
6) for. Z End of File
Uncompress all. Z
7) files ending with. tar.z
Tar-xzf All.tar.z
In addition, there are methods for extracting common compressed files under window, zip and. Rar,linux.
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 are just a brief introduction, still 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. rar files 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; available from http://www.rarsoft.com/download.htm download rarfor Linux 3.2.0, then install:
# TAR-XZPVF Rarlinux-3.2.0.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. They have a lot of parameter options, here are just a brief introduction, still examples of its use:
# rar a All *.jpg
This command compresses all. jpg files into a RAR package named All.rar, which will automatically append the. rar extension to the package name.
# Unrar E All.rar
This command extracts all the files in the All.rar.
To this, we have introduced the Linux tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, RAR, Unrar and other software, you should have been able to use them to. tar,. GZ,. tar.gz,. tgz,. bz2,. tar.bz2,. Z,. Tar. Z,. zip,. rar 10 Kinds of compressed text
, you should not need to download a software and do not know how to solve Linux under the trouble. And the above methods are basically effective for UNIX.
Three introduces the meaning of the various parameters of tar
Because the tar parameters are many, a lot of people just when the contact is rote, do not know the meaning of the options, I will explain in detail here, let everyone at a glance.
1. Build a Tar Package (package)
command format:
tar cvf tar package file name. Files or directories backed up by Tar
function Description:
The tar CVF command is used to package a specified directory or file into a specified file
the. "C" specifies that the TAR package is established (or compressed), and the "V" setting command executes
For more information, "F" specifies the file name of the tar package.
C:create;v:verbose (lengthy); F:file.
In addition, when using the tar command, you can add a short CVF front
horizontal line-or not.
but when using other Linux commands, if the command is followed by a
option, you must precede the option with a dash-.
2. Release the TAR package (also called unpack)
command format:
tar xvf tar package file name. Tar
function Description:
The Tar xvf command is used to release the contents of the specified tar package file. "X" Generation
The table releases (or extracts) the file. X:extract (extract).
Note:
tar itself is just packaging, not compression. Only a few options are added
after, such as: Z, J, etc., only on the basis of packaging compression.
that is,. Tar is just a packaged file, not a compressed file.
If you follow some extensions after. tar, such as:. tar.gz (or. tgz),
tar.bz2 (or. tbz2) is the compressed file, which is exactly packaged and compressed
3. Build a compressed TAR package (package first, then compress)
command format:
Tar ZCVF Compressed tar package file name tar.gz (or. tgz) backed up files or directory names
function Description:
"Z" means the ability to invoke the GZIP compression program, used in conjunction with C, to indicate
to build a tar package, and to build a compressed tar package. The Tar ZCVF command assigns the specified
the directory or file is packaged and then compressed and saved to the specified file. Built
The extension of a compressed tar package file is typically. tar.gz. Z:gzip.
Description: In the tar command, an option z is used to indicate the execution of the
in the process of the tar command, the GZIP program is called to the first generated
the Music.tar file package is compressed.
So, we're in the specified command format, "Compress the tar package file name"
, specify the extension. Tar before you specify the extension. gz.
4, Release the compressed tar package (unzip first, then unpack the package)
command format:
Tar zxvf Compressed tar package file name. tar.gz (or. tgz)
function Description:
The tar zxvf command extracts and releases the specified compressed tar package file from the
content. "Z" stands for extracting files.
"
The above command:
1. Tar zcvf compress the tar package file name. Files or directory names backed up by tar.gz (or. tgz)
2. Tar zxvf Compressed tar package file name. tar.gz (or. tgz)
is to compress and decompress files with the extension. tar.gz.
In addition, there are files with the extension. tar.bz2 (tbz2). The command that is used at this point is:
//Compression
1. Tar jcvf compress the tar package file name. Files or directory names backed up by tar.bz2 (or. tbz2)
//Unzip
2. Tar jxvf Compressed tar package file name. tar.bz2 (or. tbz2)
"
5. Query the files in the tar package
command format:
tar tf tar package file name. Tar
function Description:
The tar tf command displays a list of file directories in the specified tar package that is used to
understand the files that are contained in the TAR package before releasing it.
6. Query the files in the compressed tar package
command format:
tar ztf tar package file name. tar.gz (or. tgz)
function Description:
The tar ztf command displays a list of file directories in the specified compressed tar package, which
make a call to gzip to extract and then display the list of file directories.
Linux compressed files and compression options in a detailed