Linux file archiving and compression (learning notes 8), file archiving learning notes

Source: Internet
Author: User

Linux file archiving and compression (learning notes 8), file archiving learning notes
I. Archiving and Compression

  • Compression command tool: gzip, bzip2
  • Archive command tool: tar
Ii. Compression

2.1. gzip

Gzip is a standard and widely used utility for File compression and decompression. Gzip allows the Union of files. Use gzip to compress the file and you can get the tarball package file in the format of "* .tar.gz" or "*. tgz.

Gzip options

  • -Stdout: Write the output to the standard output device.
  • -To-stdout: Write the output to the standard output device.
  • -Decompress: decompress the file.
  • -Uncompress: Decompress the file.
  • -D: Decompress the file.
  • -F: forcible compression/decompression.
2.2, bzip2

Bzip2 will get a higher compression ratio than gzip

Command: bzip2 [Option] [file name] parameter-c sends the compressed/unzipped result to the standard output-d to decompress the specified target file. -Z enforces compression, whether it is the compression command bzip2 or the decompression command bunzip.-k to retain the original file during the compression or decompression process. -F indicates mandatory overwrite. -T checks the integrity of the specified compressed file, but does not decompress the file. -S reduces memory usage. -V shows the compression ratio of the compressed file. -- Process files starting with "-", for example, bzip2 ---filename -- help: displays help-num to adjust the compression speed with the specified number, -1 or -- fast indicates the fastest compression (low compression ratio),-9 or-best indicates the slowest (high compression ratio), and the default value is 6. iii. Archiving

An archive file is a compressed file consisting of one or more computer files and metadata.

3.1 archiving features
  • Data Compression
  • Encryption
  • File Union
  • Automatic Decompression
  • Automatic Installation
  • Source volume and media information
  • File spanning
  • Checksum
  • Directory structure information
  • Other metadata (data about data)
  • Error discovery
3.2. tar command:

Tar is a standard archiving application software tool for UNIX/Linux. In the early stages, it used to be a tape archiving software, and then gradually developed into a General Archive software package that can process various types of archive files. Tar can accept many archive filters with options.

Tar option-A: add the tar file to the end of the existing archive. -C: Create a new archive file. -D: Use the specified file system to compare archives. -J: compress and archive with bzip. -R: add the file to the end of the existing archive. -T: list existing archived content. -U: update the archive. -X: Extract files from existing archives. -Z: Compressed and archived with gzip. -Delete: delete an object from an existing archive.

View graphics:

Create an archive file:

[Root @ model Documents] # tar-zcvf test4.tar.gz test4 // use the test4 folder as the archive file test4/test4/hh.txt test4/yy.txt test4/a.txt test4/test [root @ model Documents] # lsa.txt com file1.txt httpd. conf test1 test4.tar.gzb.txt c.txt file2.doc test test4 tests [root @ model Documents] #

Decompress the archive file:

[root@model tar]# tar -zxvf test4.tar.gz test4/test4/hh.txttar: test4/hh.txt: time stamp 2015-02-20 06:09:01 is 17199.007385938 s in the futuretest4/yy.txttest4/a.txttar: test4/a.txt: time stamp 2015-02-20 06:09:01 is 17199.006267373 s in the futuretest4/testtar: test4/test: time stamp 2015-02-20 06:09:01 is 17199.005671909 s in the future[root@model tar]# lstest4  test4.tar.gz[root@model tar]# 

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.