Linux Advanced Command (VI): compression and decompression command can be used to complete the command tar file compression and decompression

Compression and decompression command


learning target

  • Able to use the tar command to complete file compression and decompression

1. Introduction compression format

Linux compression format supported by default:

  • .gz
  • .bz2
  • .zip

Description:

  • .gz and .bz2 compression needs to use the tar command to compress and decompress
  • .zip compression needs to use the zip command to compression, unzip command to decompress

Compression Purpose:

  • Save disk space

Use 2. tar command and options

command Explanation
takes Compression and decompression command

tar command options:

Options Explanation
-c Create a package file
-v Details display packing or unpacking
-f Specify the file name, you must put all options back
-from Compressing or decompressing (.gz)
-j Compressing or decompressing (the .bz2)
-x Unpack
-C Unzip to a specified directory

FIG .gz is compressed into effect:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-pURyPn9f-1583934746932) (imgs / tar-1.png)]

FIG .bz2 compressed into effect of:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-saWUozWK-1583934746933) (imgs / tar-2.png)]

FIG .gz decompression effect of:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-sLtPEZCa-1583934746934) (imgs / tar-3.png)]

Decompression to the specified directory .gz renderings:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-YnrfzDQT-1583934746934) (imgs / tar-4.png)]

FIG .bz2 decompression effect of:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-KPhjYQzZ-1583934746935) (imgs / tar-5.png)]

Decompressing .bz2 to the specified directory renderings:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-MnVjjvmv-1583934746935) (imgs / tar-6.png)]

Use 3. zip and unzip commands and options

command Explanation
zip Into a .zip file format
unzip Unzip the .zip file format

unzip command options:

Options Explanation
-d Unzip to a specified directory

FIG .zip is compressed into effect:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-3dxlmpJv-1583934746936) (imgs / zip-1.png)]

FIG .gz decompression effect of:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-ojT2Vtzh-1583934746936) (imgs / unzip-1.png)]

Decompress .zip to the specified directory renderings:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-GFPgVU3n-1583934746936) (imgs / unzip-2.png)]

Description:

  • .Gz compressed file format as much as possible to use, as there is less space
  • Use the zip command more compressed files take up space, then more generic, more simple operation.

4. Summary

  • .gz and .bz2 compressed files using the tar command to complete the compression and decompression
  • .zip compressed files using zip and unzip command to complete compression and decompression
Published 698 original articles · won praise 929 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_35456045/article/details/104806854