Linux tar decompression command summary

tar

 

-c: create a compressed archive
-x: decompress
-t: view content
-r: append files to the end of the compressed archive
-u: update the files in the original compressed package

These five commands are independent, and one of them should be used for compression and decompression. It can be used in conjunction with other commands, but only one of them can be used. The following parameters are optional when compressing or decompressing archives as needed.

-z: with gzip attribute
-j: with bz2 attribute
-Z: with compress attribute
-v: show all processes
-O: unpack file to stdout

The following parameter -f is required

-f: Use the file name, remember, this parameter is the last parameter, only the file name can be followed.

# tar -cf all.tar *.jpg 
This command is to type all .jpg files into a package named all.tar. -c means to generate a new package, -f specifies the file name of the package.

# tar -rf all.tar *.gif 
This command is to add all .gif files to the all.tar package. -r means to add files.

# tar -uf all.tar logo.gif 
This command is to update the logo.gif file in the original tar package all.tar, -u means to update the file.

# tar -tf all.tar 
This command is to list all the files in the all.tar package, -t means to list the files

# tar -xf all.tar 
This command is to unpack all files in the all.tar package, -x means unpack


compression

  • tar –cvf jpg.tar *.jpg Packs all jpg files in the directory into tar.jpg
  • tar –czf jpg.tar.gz *.jpg After packaging all jpg files in the directory into jpg.tar, and compressing it with gzip, a gzip compressed package is generated, named jpg.tar.gz
  • tar –cjf jpg.tar.bz2 *.jpg After packaging all jpg files in the directory into jpg.tar, and compressing it with bzip2, a bzip2 compressed package is generated, named jpg.tar.bz2
  • tar –cZf jpg.tar.Z *.jpg After packaging all jpg files in the directory into jpg.tar, and compressing it with compress, a umcompress compressed package is generated, named jpg.tar.Z
  • rar a jpg.rar *.jpg rar format compression, you need to download rar for linux first
  • zip jpg.zip *.jpg zip format compression, you need to download zip for linux first 

decompress

  • tar –xvf file.tar to decompress the tar file
  • tar -xzvf file.tar.gz 解压 tar.gz
  • tar -xjvf file.tar.bz2 解压 tar.bz2
  • tar –xZvf file.tar.Z decompress tar.Z
  • unrar e file.rar depressurar
  • unzip file.zip unzip zip

Summarize

  1. *.tar decompress with tar –xvf
  2. *.gz decompress with gzip -d or gunzip
  3. *.tar.gz and *.tgz decompress with tar –xzf
  4. *.bz2 decompress with bzip2 -d or with bunzip2
  5. *.tar.bz2 decompress with tar –xjf
  6. *.Z decompress with uncompress
  7. *.tar.Z decompress with tar –xZf
  8. *.rar decompress with unrar e
  9. *.zip unzip with unzip

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326458851&siteId=291194637