Linux Admin Learning------tar Archive and compression

Source: Internet
Author: User
Tags bz2

What the 1.1 archive means

– Organize a number of fragmented files into one file

– The total size of the file is basically the same

1.2 Meaning of compression

– Reduce the amount of space occupied by a file by an algorithm

– Decompression by corresponding inverse algorithm when recovering

Compressed format:

gzip------->.gz

BZIP2---->.BZ2

XZ------->.xz

1.3 Tar Integrated Backup tool

–-c: Creating an Archive

–-x: Release Archive

–-f: Specify the archive file name

–-z,-j,-j (uppercase): Call the. GZ,. bz2,. xz Format tools for processing

–-t: Displays a list of files in the archive

–-p (uppercase): Keep the absolute path to the file within the archive

–-c (UPPERCASE): Specifies where the TAR package is disposed

Use tar-c ... Command

–TAR-ZCF backup files. tar.gz The document that was backed up ....

–TAR-JCF backup files. tar.bz2 The document that was backed up ....

–TAR-JCF backup files. tar.xz The document that was backed up ....

tar-zcf/opt/file.tar.gz/boot//home/#将/boot/home packaged in gzip format

Tar-cf/opt/123.tar/boot #将/boot content package, no format

Gzip/opt/123.tar #以gzip格式解包

Tar -jcf /opt/test.tar. bz2 /boot//home/

Tar -jcf /opt/abc.tar. XZ /boot//home/

Tar-xf/opt/file.tar.gz- C /mnt/

–-t: Displays a list of files in the archive

–-p (uppercase): Keep the absolute path to the file within the archive

Experimental cases:

[Email protected] ~]# rm-rf/opt/* #为确保能清楚知道接下来发生了什么

[Email protected] ~]# echo 123456 >/opt/1.txt

[Email protected] ~]# Tar-zcpf/mnt/1.tar.gz/opt/1.txt

[Email protected] ~]# rm-rf/opt/1.txt #删除/opt/1.txt

[[email protected] ~]# cd/mnt/#不要在/opt Decompression

[Email protected] mnt]# TAR-XPF 1.tar.gz

[Email protected] mnt]# ls/opt #发现/opt the 1.txt is back.

Summary:-P compression and decompression is to appear in pairs, if the compression when written, and when the decompression did not write, in which path under which the decompression is displayed.

1.4zip Compression and archiving

Zip: Cross-platform (Windows vs. Linux)

Command format: Zip [-r]/path/backup file. zip/path/archived document.

[email protected] ~]# zip-r/opt/test01.zip/home//boot/#压 Shrink-r recursive processing, processing all files and subdirectories under the specified directory

[Email protected] ~]# ls/opt

[Email protected] ~]# unzip/opt/test01.zip-d/mnt/#解压

[Email protected] ~]# zip-r/opt/test02.zip/etc/selinux

[Email protected] ~]# ls/opt

[Email protected] ~]# unzip/opt/test02.zip/mnt


Linux Admin Learning------tar Archive and compression

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.