Summary of common linux decompression commands

Source: Internet
Author: User
Linux common decompression commands summary linux decompression tar command tar [-cxtzjvfpPN] files and directories .... parameter:-c: create a compressed file parameter command (create);-x: unlock a compressed file parameter command! -T: check the tarfile... linux common decompression commands summary linux decompression tar command tar [-cxtzjvfpPN] files and directories .... parameter:-c: create a compressed file parameter command (create);-x: unlock a compressed file parameter command! -T: view the files in the tarfile! Note that c/x/t can only exist under the parameter! Cannot exist at the same time! Because it is impossible to simultaneously compress and decompress. -Z: does it have the gzip attribute at the same time? That is, do I need to use gzip for compression? -J: does it have bzip2 attributes at the same time? That is, do I need to use bzip2 for compression? -V: The file is displayed during compression! This is common, but it is not recommended to use it in the background execution process! -F: use the file name. please note that the file name should be followed immediately after f! Do not add parameters! For example, if you use "tar-zcvfP tfile sfile", it is wrong to write it as "tar-zcvPf tfile sfile! -P: use the original attributes of the original file (the attributes will not be changed based on the user)-P: you can use absolute paths to compress! -N: a new date (yyyy/mm/dd) will be packed into the new file! -- Exclude FILE: Do not pack the FILE during compression! Example: Example 1: package all the files in the/etc directory into/tmp/etc.tar [root @ linux ~] # Tar-cvf/tmp/etc.tar/etc <= package only, do not compress! [Root @ linux ~] # Tar-zcvf/tmp/etc.tar.gz/etc <= compressed with gzip [root @ linux ~] # Tar-jcvf/tmp/etc.tar.bz2/etc <= after packaging, compress with bzip2 # note that the file name after parameter f is obtained by yourself, we are used to it all. tar. # If the z parameter is added, .tar.gz or. tgz is used to represent the tar file ~ compressed by gzip ~ # If you add the j parameter, use .tar.bz2 as the file name ~ # When the preceding command is executed, a warning message is displayed: # "tar: Removing leading '/" from member names ", which is a special setting for absolute paths. Example 2: Check the files in the above/tmp/etc.tar.gz file? [Root @ linux ~] # Tar-ztvf/tmp/etc.tar.gz # because gzip is used for compression, when you want to check the files in the tar file, # add the z parameter! This is important! Example 3: decompress the/tmp/etc.tar.gz file under/usr/local/src [root @ linux ~] # Cd/usr/local/src [root @ linux src] # tar-zxvf/tmp/etc.tar.gz # By default, we can unbind the compression file anywhere! In this example, # first change the working directory to the/usr/local/src directory, and unlock/tmp/etc.tar.gz, # The unlocked directory will be in/usr/local/src/etc! In addition, if you enter/usr/local/src/etc #, you will find that the file attributes in this directory may be different from those in/etc! Example 4: Under/tmp, I only want to unbind the etc/passwd in/tmp/etc.tar.gz [root @ linux ~] # Cd/tmp [root @ linux tmp] # tar-zxvf/tmp/etc.tar.gz etc/passwd # I can check the file name in the tarfile through tar-ztvf, if you only need one file, # you can issue it in this way! Notice! The root directory in etc.tar.gz/is removed! Example 5: Back up all the files in/etc/and save their permissions! [Root @ linux ~] # Tar-zxvpf/tmp/etc.tar.gz/etc # This-p attribute is very important, especially when you want to keep the attributes of the original file! Example 6: In/home, only new files larger than 2005/06/01 are backed up [root @ linux ~] # Tar-N "2005/06/01"-zcvf home.tar.gz/home Example 7: I want to back up/home,/etc, but do not/home/dmtsai [root @ linux ~] # Tar -- exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc example 8: Pack/etc/and Unbind It Under/tmp without generating a file! [Root @ linux ~] # Cd/tmp [root @ linux tmp] # tar-cvf-/etc | tar-xvf-# This action is a bit like cp-r/etc/tmp ~ It is still useful! # Note that the output file is changed to-and the input file is changed to-, and there is another file | yes ~ # This represents standard output, standard input, and pipeline commands respectively! # In Bash shell, we will mention this command again to explain it ??? /Div> -------------------------------------- extract the cpio file cpio-idmv <filename. cpio can also decompress the imgfile: cpio-idmv <filename. imgcpio backup command backup: cpio-covB> [file | device] back up data to a file or device to restore: cpio-icduv <[file | device} restores data to the system. common parameter:-o: copy data to a file or device-I: restore data from a file or device to the system-t: view the file or device content created by cpio-c: a new portable format storage-v: display the file name B during the backup process on the screen: increase the preset blocks size to 5120 bytes. the default value is 512 bytes. this will speed up the backup.-d: automatically create a directory, in this way, the path cannot be found during restoration-u: update, when a newer file is used to overwrite the old file cpio, it is often used with find to decompress * rarfile unrar x aa.rar unrar e aa.rar x. The parameter is extracted to a folder. the parameter e is used to extract all files the first method of listing in the current directory: zcat restart | cpio-idmvzcat lnx_920_disk1.cpio.gz | cpio-idmvzcat lnx_920_disk1.cpio.gz | cpio-idmv Method 2: Step 1: gunzip restart zookeeper Step 2: cpio-idmv <lnx_920_disk1.cpiocpio-idmv <lnx_920_disk2.cpiocpio-idmv <lnx_920_disk3.cpio
Related Article

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: 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.