Linux System decompression/compression command parsing

Source: Internet
Author: User
Tags bz2 uncompress

1) Zip and unzip command

Zip-r Myfile.zip./* Compresses all files and folders in the current directory into Myfile.zip files, and-r means all files in the recursive compressed subdirectory.

Unzip-o-d/home/sunny myfile.zip Unzip the Myfile.zip file to/home/sunny/,-o: Overwrite the file without prompting,-D: Indicates that the file is extracted to the/home/sunny directory.

zip-d myfile.zip smart.txt Delete the Smart.txt file in the compressed file.

Zip-m myfile.zip./rpm_info.txt add rpm_info.txt files to the myfile.zip in the compressed file.

Zip-r filename.zip file1 file2 file3/usr/work/school The above command to compress file1, file2, File3, and/usr/work/school contents to Filen The Ame.zip file.


2) Tar command

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

When using this command, the main option is required, and it tells Tar what to do, auxiliary options are auxiliary and can be used.

Main options:

C Create a new profile. Select this option if the user wants to back up a directory or some files.

R appends the file to be archived to the end of the archive file. For example, you can use this option to append a forgotten directory or file to a backup file if you have already made a backup file and you find that there is a directory or some files that you forgot to back up.

T list the contents of the archive file and see which files have been backed up.

U update file. That is, replace the original backup file with the new file, if the file you want to update is not found in the backup file, append it to the end of the backup file.

X release the file from the archive file.

Accessibility Options:

b This option is set for the tape drive. It is followed by a number that indicates the size of the chunk and the system preset value is (20*512 bytes).

F using a file or device, this option is usually required.

K Save the file that already exists. For example, we restore a file, during the restore process, encountered the same file, will not be overwritten.

m when restoring files, set the modification time of all files to now.

M Create a multi-volume archive file for storage on several disks.

V Detailed report of file information processed by tar. Without this option, TAR does not report file information.

W each step requires confirmation.

Use gzip to compress/unzip the file, plus this option to compress the archive file, but be sure to unzip it using this option when restoring.

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

-C: Build compressed archives tar-cf file.tar *.jpg This command is to make all. jpg files into a package called File.tar. -C: Indicates that a new package is generated,-F: Specifies the file name of the package.

-X: Decompression tar-xf File.tar This command is to solve all the files in the File.tar package,-T is to untie the meaning.

-T: View content TAR-TF File.tar This command is to list all the files in the File.tar package,-T is the meaning of the list file.

-r: Append files to the end of the compressed archive tar-rf file.tar *.gif This command adds all the. gif files to the File.tar package. -R is meant to increase the file.

-u: Update the files in the original package Tar-uf file.tar logo.gif This command is to update the original tar package File.tar logo.gif file,-U is to indicate the meaning of the update file.

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.

(1) Tar call gzip

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 file.tar.gz *.jpg This command is to make all. jpg files into a tar package and compress them in gzip to generate a gzip compressed package named file.tar.gz

TAR-XZF file.tar.gz This command is to untie the package generated above.

(2) Tar call bzip2

Bzip2 is a more compressible compression program, 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 gzip.

TAR-CJF file.tar.bz2 *.jpg This command is to make all. jpg files into a tar package and compress them in bzip2, generating a bzip2 compressed package named file.tar.bz2

TAR-XJF file.tar.bz2 This command is to untie the package generated above.

(3) Tar call compress

Compress is also a compression program. The file at the end of Z is the result of bzip2 compression. The decompression procedure relative to compress is uncompress. Use the-Z parameter in tar to invoke gzip.

TAR-CZF file.tar.z *.jpg This command is to make all. jpg files into a tar package and compress them in compress, generating a uncompress compressed package named File.tar.z

TAR-XZF file.tar.z This command is to untie the package generated above

3) RAR and Unrar commands need to download RAR for Linux first

RAR a jpg.rar *.jpg rar format compression

Unrar e file.rar rar format decompression

4) Decompression Method identification

1, *.tar with TAR–XVF decompression

2, *.gz with gzip-d or gunzip decompression

3, *.tar.gz and *.tgz with TAR–XZF decompression

4, *.bz2 with bzip2-d or with BUNZIP2 decompression

5, *.tar.bz2 with TAR–XJF decompression

6, *. Z Extract with Uncompress

7, *.tar. Z Extract with Tar–xzf

8, *.rar with Unrar e decompression

9, *.zip with unzip decompression

Linux System decompression/compression command parsing

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.