[]linux of various compressed packages in reprint

Source: Internet
Author: User
Tags gz file unpack uncompress wrapper zip extension

Table 1 Linux common compression and decompression command description

Common commands

Brief Chinese description

directory where the program is located

Gzip

Compressed to a file named. GZ (also available as –d option to unzip)

/bin

Gunzip

Unzip the. GZ compressed file (can be replaced with gzip plus –d parameter)

/bin

Tar

Package files packaged as. Tar or unpacked (you can also call gzip with the –Z option to compress or unzip the. gz file)

/bin

Compress

Compressed into a file named. Z compressed file (also available –d option to unzip)

/usr/bin

Uncompress

Will. Z compressed file decompression (can be replaced with Compress plus –d option)

/usr/bin

Zip

Packaged and compressed into a file named. zip file (itself does not have the ability to decompress, be sure to use unzip to extract the line)

/usr/bin

Unzip

Unzip the. zip file

/usr/bin

Bzip2

Compressed to a file named. bz2 (also available –d option to unzip)

/bin

Bunzip2

Unzip the. bz2 compressed file (can be replaced with bzip2 plus –d option)

/bin

  gzip [- option ] [ file name ]

compressed into a file named . GZ the compressed file

If you see A. gz,. tar.gz file, it is a masterpiece of gzip program compression.

Gzip is a compression program developed by the GNU organization that is not quite the same as the ZIP on Windows (one will be introduced later).

Let's first introduce the compression method. When we have a file called Big1.bmp, because bitmap files are usually very large, to use gzip compression, command how to do?

The simplest of these can be:

Gzip Big1.bmp

But if you want it to press out the "smallest file", then add a-9 option:

Gzip-9 big1.bmp

Of course, the "smallest file" cost is the longest time to compress, if you want it to compress in the fastest time, rather than the compression ratio, then instead, add a-1 (note, is the number, not the lowercase English l) option:

Gzip-1 big1.bmp

And if you don't have plus-1 and no plus-9, it's the default equivalent of-6.

Other commonly used options are:

L-v the progress during the compression process.

L-r the files in the subdirectory are all compressed.

As for the option of extracting it, we deliberately move it to the next command gunzip again.

------------------------------------------------------------------------------------------------------------

gunzip [- options ] [ file name . gz]

will be . GZ Compressed File Decompression

The Gunzip command, in contrast to the gzip command, specifically compresses the gzip compressed. gz file. If you have files that have already been compressed, such as big1.gz, then you can extract them:

Gunzip big1.gz

This command can also be done with Gzip itself, with exactly the same effect:

Gzip-d big1.gz

In fact, on some versions of Linux, Gunzip is going to call gzip, and by the way you add a-D option (made with a link file)! But some versions are not, is a real program. But whether Gunzip is a real program or just a connection, it doesn't matter. Because gzip this program, itself can be responsible for compression, can also decompress, a thing dual-use. (This is not necessarily the case for every compression and decompression program.) So, if you remember the-D option, you don't have to remember the gunzip command at all.

Gunzip can even extract files that are compressed by other compression programs such as Compress or ZIP. However, we do not recommend that you do this, it will make you very messy. And it admits that using it to extract zip files is not something that can be done in every situation. So why bother? What kind of tools are fixed for what, not more organized and good to remember?

Gunzip has several options to use more often:

L-f when the decompression if you encounter a file with the same name exists, it is directly overwritten, no need to ask.

L-r all the files in the subdirectory are uncompressed.

L-v to show progress during decompression.

Again, these options can be added to the gzip-d, with the same effect.

------------------------------------------------------------------------------------------------------------

tar [- options ] [ package file name ] [ file ]

packaged as . Tar the package file or unpack

If you have really tried gzip, or if you have experience using DOS, Windows ARJ, ZIP-type programs, you will find that Gzip has a fatal disadvantage: it can only compress one file. Even for sub-directory compression, it is also for individual file compression in subdirectories, and does not crush them into a tight "package".

So on Linux, this "bag" task is used by the TAR program to do it. Note that tar is not a compression program, because the size of the package is as large as it was originally packaged. So it's not a compression program, but a wrapper. And we're used to packing, producing a. tar file, and then compressing the package. The file name of tar.gz.

Some people feel that. tar.gz such a name is too long, in fact condensed into. tgz, the meaning is the same.

The TAR option is up to 53. (You can see it with man tar) but not so much in practice, and the same few days of reuse. So we have a direct example:

TAR-CF New1.tar My1*.doc

Package all my1*.doc files into a New1.tar file. Where-C is the generation of new files,-f is output to the default device, you can think of it as a certain option to add.

TAR-RF New1.tar My2*.doc

New1.tar is a packaged file that already exists. We'll also pack all the My2*.doc files. -R is the meaning of adding the file again.

Tar-uf New1.tar My18.doc

Just My1*.doc has been packaged in, but My18.doc later made changes, we put the newly changed files re-packaged in,-U is updated meaning.

Speaking of which, if you've ever used a ARJ program, you might think it's a bit stupid. Because the ARJ program is similar to the above 3 procedures, all can be manipulated with a single a option, right? If you don't use ARJ, keep looking down.

TAR-TF New1.tar

List what files are packaged in the New1.tar. -T is the list of meanings. This option is much like the L option of the ARJ program.

TAR-XF New1.tar

Solve all the files in the New1.tar package file, and-X is untied.

TAR-XF New1.tar My2*.doc

Just unpack all the My2*.doc files in the New1.tar package file, and-X is untied. This option is much like the x option of the ARJ program.

Did you notice? It is also similar to the ARJ program, it can be responsible for packaging, can also be responsible for unlocking, without the need for another decompression program. And the difference between it and ARJ once again, is no compression ability!

However, I can borrow it from the GZIP program! Like a convenience store without a bakery, you can sell bread on your behalf! For consumers, it's the same. The-Z option is the secret stock pipeline!

TAR-ZCF new1.tar.gz My1*.doc

Please note that this command differs from the same command. First, with the z option, it will borrow the compression capability to gzip; second, note that the resulting filename is new1.tar.gz, two processes, one complete!

If you want to work with the Compress program (described later), compress another. Tar. Z file, then just change the-Z option to the-Z option.

TAR-ZCF New1.tar.z My1*.doc

Finally, we add an option-V, which is the process of packing and compressing or decompressing. So this is what you see most often (because the most common software wrapper files on Linux are. tar.gz files):

TAR-ZXVF onepackage.tar.gz

If it is a. tgz file name is the same, because the same nature, just the file name is simple:

TAR-ZXVF onepackage.tgz

This-ZXVF option can be almost fixed and worthy of your back. And how did this file come to be generated? This may be true (you can also back up and later make it easy for you to build your own. tar.gz file):

TAR-ZCVF onepackage.tar.gz * *

Or

TAR-ZCVF onepackage.tgz * *

------------------------------------------------------------------------------------------------------------

Compress [- options ] [ filename ]

compressed into a file named . Z of compressed Files

Compress is similar to gzip and is a compression and decompression tool. If you see. Z,. Tar. Z files are masterpieces of Compress program compression.

Let's first introduce the compression method. Suppose we have a glyph file called taipei24.pcf, the font file is usually very large, to use compress compression, how to command the next?

The simplest is this:

Compress taipei24.pcf

It will produce a taipei24.pcf.z compressed file.

Other commonly used options are:

L-v shows progress and proportions during compression.

As for the option of extracting it, we deliberately move it to the next command uncompress.

Practice:

(1) using gzip and compress to compress the same file, which kind of compression effect is better?

(2) What commands are required to package all a*.pcf files through the tar command and then compress compress to become a afont.tar.z file?

  uncompress [- options ] [ filename . Z]

will be . Z Compressed file decompression

The uncompress command, in contrast to the Compress command, specifically compresses the compress. Z file to unzip. If you have files that have already been compressed, such as one. Z, then you can use

Uncompress one. Z

can also be done with compress, the effect is exactly the same:

Compress-d one. Z

Currently most versions of Linux, uncompress actually just to call compress, by the way to help you add a-D option (with the link file), is not a real program.

Because compress the program itself can be responsible for compression, can also be decompressed, one thing dual-use. (This is not necessarily the case for every compression and decompression program.) So, if you remember the-D option, you don't have to remember the uncompress command at all.

Uncompress General will use the option is about one:

-V Shows progress during decompression.

Again, these options can be added to the compress-d, with the same effect.

------------------------------------------------------------------------------------------------------------

zip [- options ] [ file name . zip] [ file name ]

packaged and compressed into a file named . zip of the file

Zip and gzip are only one letter short, but the usage is much worse.

The format used by Zip is exactly the same as DOS and. zip on Windows. In other words, it does not need to be packaged and compressed two procedures, you can produce two kinds of utility "compressed file package." And, if you use this format, you can easily pass between Windows and Linux, just like. bmp,. jpg,. gif, and more. For example, you can use the WinZip program in Windows to untie, or use WinZip to press the. zip directly to Linux.

Since it's so good, why don't people use it? Don't ask me, I don't know. Computer in the world often there is a strange phenomenon, good things are not used by everyone, we are often used is not the best choice, or just listen to predecessors such use, he followed this use.

In short, if you think people are not using things, is not good, it is probably wrong. In the end, find someone to analyze why you use something like that? What are the advantages? "Universal"! can also become one of the advantages, strange!

Zip-packaged and compressed commands like this (it's up to 36 options, but believe the following should be enough for you):

Zip New1.zip My1*.doc

Package all my1*.doc files into a new1.zip file. New1.zip can omit the extension abbreviated to NEW1, which will default to the. zip extension itself.

zip-d New1.zip My18.doc

If the original My18.doc was a file that was compressed in New1.zip, this command now removes it from the compressed file and deletes it. -D is the meaning of the deletion.

Zip-g New1.zip My32.doc

If the my32.doc was not pressed in the New1.zip, now add it in. The-G option is meant to increase rather than regenerate (grow, grow up, this letter is used to be a bit more special).

Zip-u New1.zip My2*.doc

If the original my2*.doc have been compressed into the new1.zip inside, but later My2*.doc several files have changed, and do not want to find out exactly what the file changes, this command please the system to help check, change the update to compression, otherwise do not move. -U is the meaning of the update.

Zip-r New2.zip Mydir

If Mydir is a directory name, it compresses all the files of the entire directory into a single new2.zip file. The-r option is meant to compress subdirectories.

What about the Unzip option? Sorry, zip can only be compressed, there is no part-time decompression feature. Decompression please use unzip.

------------------------------------------------------------------------------------------------------------

Unzip [- options ] [ file name . zip] [ file name ]

will be . zip Compressed File Decompression

Zip and unzip this set of programs is really a pair of partners. The ZIP program itself does not have the ability to decompress, be sure to use the Unzip program to extract the line. Unzip is a real program, not a zip alias.

Because the ZIP program will be a large number of files compressed together, and when decompressed, it is possible that some of these files have already existed (if none exist, of course, very simple), so there are some intricate, tangled lingering decompression situation, you have to have the heart ready! For example, do we have to overwrite these existing documents unconditionally, or will we only overwrite them with new ones? or whether the old and new, only the non-existent files are compressed plus go, or every time you encounter a file exists, you have to ask me, let me decide? The so-called existing, is the use of UNIX discrimination, or the rule of DOS? In other words, if there is an uppercase myfile in the compressed file, does it have a file with the same name as the existing lowercase myfile, or does it count as a file with the same name?

Also, because the zip can compress the entire subdirectory, then the decompression, there will be an unavoidable choice situation: you want to extract back to the same location as the original directory, or the existing directory to extract and generate the directory?

Because the situation above is too complex, we only List A sample command, and then all the other options are listed directly:

Unzip Onepackage.zip A*.doc

The onepackage.zip inside the general A*.doc all extracted out. If the A*.doc file name is not entered, all onepackage.zip will be decompressed. However, it is best to match the following options to determine 8 processing decisions when you encounter the same file name:

-F only unzip the files that have been updated, other files are not under pressure (but will be asked when updating).

-U unzip to update the existing file and unzip the nonexistent file (but will ask when updating).

-FO only unzip the files that are already existing, other files are not under pressure (but do not ask for direct overwrite updates).

-uo unzip the existing file and unzip the nonexistent file (but does not ask for a direct overwrite update).

-O Regardless of whether the file is new or old, unzip it from the compressed file and overwrite it directly.

-N only extracts non-existent files, the existing files are kept intact regardless of the old and new.

-C does not care about the difference in case, as the same file name (default is considered different).

-L unzip the file name to lowercase.

Also, the processing decision when encountering subdirectories:

-j regardless of the original compression of the directory, are all untied in the current directory.

-D followed by a directory name. You can specify the extract to this directory.

One of the other common options:

-l lists only the files in the compressed package and does not really unlock the compression.

------------------------------------------------------------------------------------------------------------

bzip2 [- options ] [ filename ]

compressed into a file named . bz2 the compressed file

BZIP2 is a new generation of compression programs, but still can't change the gzip: Only one file can be compressed, to package also rely on tar to help. So you'll still see the tar.bz2 file.

Bzip2 refers to a set of text compression algorithms called Burrows-wheeler block sorting, and the famous Huffman Coding (Huffman coding), so the name begins with the word B. This compression method in the compression process will be called block of memory units, you can customize the size of the block memory units, the greater the block, the better the compression effect, of course, the more memory. We can give the 1~9 option, which uses the following memory algorithm.

When compressing:

Memory usage =400kb+ (block size X7)

Block size = option x100kb

When extracting:

Memory usage =400kb+ (block size x4)

The size of the block at the time of decompression is determined by the compression, so the option is not determined. So, when you compress, you can release commands like this:

Bzip2-9-K Myfile.doc

To compress the Myfile.doc command into the smallest file, the 9 option is actually the default. It will produce myfile.doc.bz2 files. The plus-K option indicates that although the myfile.doc.bz2 is generated, the Myfile.doc original file is retained, which is what the GZIP program does not do.

------------------------------------------------------------------------------------------------------------

bunzip2 [- options ] [ filename . bz2]

will be . bz2 Compressed File Decompression

The BUNZIP2 command, in contrast to the bZIP command, is specifically decompressed by the bZIP compressed. bz2 file. If you have files that have already been compressed, such as myfile.bz2, then you can use:

BUNZIP2 myfile.bz2

can also be done with bzip2, the effect is exactly the same:

Bzip2-d myfile.bz2

Currently most versions of Linux, BUNZIP2 actually just to call bzip2, by the way to help you add a-D option (with the link file), is not a real program.

Since the bzip2 itself can be responsible for compression, it can also be decompressed, one thing dual-use (not necessarily every compression and decompression program is so.) )。 So, if you remember the-D option, you don't have to remember the BUNZIP2 command at all.

But remember when we mentioned in the BZIP2 command, the memory required to extract the BUNZIP2/BZIP2 program is:

Memory usage =400kb+ (block size x4)

Because the size of the block at the time of decompression is determined by the compression, so the option is not determined. However, we have the opportunity to change that "x4" times. If we add the-s option to the decompression, it will calculate this:

Memory usage =400kb+ (block size x2.5)

Obviously,-s is small meaning that it can save half the memory usage.

Table 2 shows the total table of memory usage for BZIP2 and BUNZIP2 compression and decompression.

Table 2 Total Memory Usage table

Options when compressing

Compression time consumption

Amount of decompression time

Added-s option to extract the amount of time

-1

1 KB

KB

KB

-2

1 KB

KB

KB

-3

2 KB

1 KB

850 KB

-4

3 KB

1 KB

1 KB

-5

3 KB

2 KB

1 KB

-6

4 KB

2 KB

1 KB

-7

5 KB

2 KB

1 850 KB

-8

6 KB

3 KB

2 KB

-9

6 KB

3 KB

2 KB

In addition, the options commonly used by BUNZIP2 are as follows:

-V Shows progress during decompression.

-K unzip, but retains the original compressed file.

Again, these options can be added to the bzip2-d, with the same effect.

Original link: Http://wenku.baidu.com/view/a7b6645077232f60ddcca1e4.html?re=view

[]linux of various compressed packages in reprint

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.