Basic knowledge of Linux - Linux compression and decompression

Compression and decompression (for tar, gzip, zip three compression formats)

tar command

Mainly for .tar and .gz format compressed files.

  • The former is called tarball, archives files, assembles files into .tar files, and does not reduce the volume, but simply encapsulates them.
  • The latter is a gzip compressed file, using the gzip compression algorithm to greatly compress the file.

Syntax: tar [-c -v -x -f -z -C] parameter 1 parameter 2 parameter 3...

  • -c, create a compressed file
  • -v, show compression and decompression progress
  • -x, decompression mode
  • -f, the file to be created or decompressed, must be the last of all options
  • -z, gzip mode, if not used, the default is tarball mode
  • -C selects the decompression destination for decompression mode

common combination

tar -zcvf compressed file 1 compressed file 2 ... compressed file N

  • Compressed as a gzip compressed file

tar -cvf archive is compressed file 1 is compressed file 2 ... is compressed file N

  • Compressed into a tarball file
    insert image description hereinsert image description hereinsert image description here
    [gz format is significantly smaller]

tar decompression

tar -xvf ys.tar【Decompress ys.tar to the current directory】
tar -xvf ys.tar -C /home/ygggy/t1【Decompress ys.tar to the specified directory】
tar -zxvf ys.gz -C /home /ygggy/t1 [Decompress ys.gz to the specified directory]
insert image description here

zip command to compress files

Syntax: zip [-r] Compressed package is compressed file 1 is compressed file 2 ... is compressed file N

  • -r, the compressed content contains the folder, you need to use the -r option
    zip -r ys.zip t1 index.html Compress the t1 folder and index.html into ys.zip and
    insert image description here
    insert image description here
    unzip it

Use unzip to decompress the zip archive
Syntax: unzip [-d] The zip archive to be decompressed

  • -d specifies the place to unzip, if not written, the default current directory
    unzip -d ./jy ys.zip unzip ys.zip to the jy folder

Guess you like

Origin blog.csdn.net/qq_41954181/article/details/129963819