Archive command introduction.

Source: Internet
Author: User
Tags gz file

Tar

Archive tools under linux. Is to archive the file or directory into a file, but it is not compressed.
Syntax format
Tar [main options + auxiliary options] file or directory list

Primary Option
-C. Create a new archive file
-R: append the file to be archived to the end of the file.
-T list the archived files
-U updates the file and replaces the original file with the new file. If the backup file does not exist, append it to the end of the backup file.
-X restore a file from an archive file
 

Auxiliary option-f archive to common file-k to save existing files. For example, if the same file is encountered during restoration, it will not be overwritten-m when restoring the file, set the modification time of all files to the current time-v detailed tar processing process-w each step should be confirmed-z use gzip to compress/decompress the file-j use bzip2 to compress /decompress the file-Z to filter the file through the compress program.
For example, you can copy all the files in the/etc/directory to the current directory named wpc.tar by running the following command: tar cvf wpc.tar/etc/
 
For example, to extract the current directory wpc.tar, run the following command: tar xvf wpc.tar
 
======================================
File compression can be used to compress general files or archive files.
Gzip & gunzip
Syntax format: gzip [Option] compressed (decompressed) file name
Gzippered the source file into a. GZ file and deleted the original file.

Common option-c writes the output to the standard output, and retains the original file-d to decompress the compressed file-l to each compressed file, showing the field: the size of the compressed file, the size of the uncompressed file, the compression ratio, and the name of the uncompressed file-r recursively searches for the specified directory, and compresses or decompress all the files. -T check whether the compressed file is complete-v shows the file name and compression ratio for each compressed and decompressed file.-num sets the compression ratio with the specified number num, and-1 or-fast indicates the lowest compression ratio, -9 or-best indicates the maximum compression ratio. The default value is 6.
 
For example, run the following command to compress the current directory wpc.bmp: gzip-v wpc.bmp
For example, extract wpc.bmp .gz from the current directory and run the following command: gunzip-d wpc.bmp .gz.
Command result: wpc.bmp .gzis decompressed and deleted. wpc.bmp is displayed.
-------------------------------
Zip & unzip
Zips are the same as windows winzips. Zip.
Syntax format zip compressed file name compressed file list
For example, to compress all contents in the current directory into wpc.zip, run the following command: zip wpc.zip wpc/
Unzip
Syntax format: unzip [Option] compressed file name. Zip
Common options: Decompress the file in the-x file list, but do not include the file-v specified in the "file list" to view the compressed file directory. However, the-t test file is not damaged, but do not understand the pressure-d directory to extract the compressed file to the specified directory-z only displays the compressed file annotation-n does not overwrite existing files-o overwrite existing files and does not require the user confirms that-j does not recreate the directory structure of the document, decompress all files to the same directory.
 
For example, extract wpc.zip from the current directory with the following command: unzip wpc.zip
-------------------------------------------
Bzip2
Syntax format: bzip2 [Option] [-compression level] compressed file name

Common options-c or -- stdout: Send the compression and decompression results to the standard output-d or -- decompress to perform decompression-f or -- force bzip2 during compression or decompression, if the output file has the same name as the existing file, the existing file will not be overwritten by default. to overwrite the existing file, you need to use this parameter-h or -- help to display the help-k or -- keep bzip2. After compression or decompression, the original file is deleted. to retain the original file, use this parameter-s or -- small to reduce the memory usage during program execution-t or -- test .bz2 to compress the file integrity-v or -- verbose to compress or decompress the file, display detailed information-z or -- compress force compression-V or -- version display version information-repetitive-best if the file contains repeated content, this parameter can be used to improve compression performance-repetitive-fast if duplicate content exists in the file, this parameter can be used to speed up execution
 
For example, use bzip2to compress wpc.tar, the command is as follows: bzip2 wpc.tar
For example, To uncompress wpc.tar.bz2 in the current directory, run the following command: bzip2-d wpc.tar.bz2
Note: bunzip2 and bzip2-d have the same effect.
 
 

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.