Pack and compress and tar commands under Linux!

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

This article describes the packaged compression programs under Linux tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, RAR, Unrar programs, and how to use them for. Tar,. GZ,. Tar.gz,. Tgz,. bz2,. tar.bz2,. Z,. Tar. Z,. zip,. rar, 10 kinds of compressed files to operate.

There are only two of the most common compressed files under Windows, one is. zip, and the other is. rar. And under Linux it has. GZ,. tar.gz, Tgz, bz2,. Z Compressed files, of course . zip and. rar can also be used for Linux systems.

Before summing up the various types of compressed files, the first two concepts should be clarified: packaging and compression .

The concept of packing box compression :

Packaging: Refers to a large pile of files or directories into a total file,

Compression: Converts a large file into a small file through some compression algorithms.

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 a different tool to first make the whole heap of files into a package, and then the original compression program compression.

Description of the TAR command:

Syntax: tar [main option + Secondary options] file or directory

When using this command, the main option must have, which tells Tar what to do, auxiliary options are auxiliary, can be used.

Main option: " one command the following 5 parameters can only have one"

-C:--create Create a new compressed document, which is packaged

-X:--extract,--get unzip file

-T:--list, view everything in the compressed document

-r:--append appending files to a compressed document

-u:--update updating files in the original compressed package

Accessibility Options:

-Z: Do you have the properties of gzip at the same time? Do you need to compress or decompress with gzip? The general format is xxx.tar.gz or xx.tgz

-j: Do you have bzip2 properties at the same time? Is it necessary to compress or decompress with bzip2? The general format is xx.tar.bz2

-V: Show the operation process! This parameter is very common

-F: Use the document name, Note that after f you need to immediately answer the document name, no additional parameters!

-C: Switch to the specified directory

--exclude file: Do not package file during compression

Instance:

Packaging commands

# TAR-CF All.tar *.jpg to make all. jpg files into a package called All.tar. -C is the file name that represents the generation of a new package,-f specifies the package.

# TAR-RF All.tar *.gif Add all the. gif files to the All.tar package. -R is meant to increase the file.

# tar-uf All.tar logo.gif Update the original tar package All.tar logo.gif file,-U is the meaning of the update file.

# TAR-TF All.tar Lists all the files in the All.tar package,-T is the meaning of the list file.

# TAR-XF All.tar out all the files in the All.tar package,-X is the meaning of unpacking

These are the most basic uses 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. This is what tar can call other compression programs while packaging or unpacking, such as calling Gzip, bzip2, and so on.

Pack + Compress command

1. 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.

# TAR-CZF all.tar.gz *.jpg the. jpg file into a tar package and compresses it in gzip to generate a gzip compressed package named all.tar.gz

# Tar-xzf all.tar.gz to unlock the compressed package generated above

2. bzip2 is a compression program that is more compressed, 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 bzip2.

# TAR-CJF all.tar.bz2 *.jpg all. jpg files into a tar package, and call bzip2 compression to generate a BZIP2 compressed package named all.tar.bz2

# TAR-XJF all.tar.bz2 to unlock the compressed package generated above

3. 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.

# TAR-CZF All.tar.z *.jpg all. jpg files into a tar package, and call compress compression to generate a uncompress compressed package named All.tar.z
# TAR-XZF All.tar.z to untie the package generated above
Unzip command

1) for files ending in. Tar tar-xf All.tar

2) file ending with. gz gzip-d all.gz or Gunzip all.gz

3) for files ending with. tgz or. tar.gz tar-xzf all.tar.gz or Tar-xzf all.tgz
4) file ending with. bz2 bzip2-d all.bz2 or 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) for. Tar.z End of File 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 is to compress all. jpg files into a zip package

Note: If you are compressing a folder, add the-r parameter, which means that recursive compression is called, such as:

Zip-r Temp.zip Temp

# Unzip All.zip
This command is to extract all the files in the All.zip.

2) for. rar
To process the. 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; 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.

Pack and compress and tar commands under Linux!

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.