5 to Linux-compression and backup, 5 to linux

Source: Internet
Author: User

5 to Linux-compression and backup, 5 to linux

I. Common compressed files in Linux

*. Z compress compressed files (not popular now, and can be decompressed using gzip );

*. Files compressed by the gz gzip program;

*. Bz2 bzip2 compressed files;

* The data packaged by the. tar program has not been compressed;

* .Tar.gz tar package files, which are compressed by gzip

* .Tar.bz2 tar package files, which are compressed by bzip2

 

Ii. Common compression commands

1. gzip compressed to gzip

Gzip [-cdtv #] File Name

Options and parameters:

-C: outputs compressed data to the screen and can be processed through data stream redirection;

-D: extract parameters;

-T: it can be used to check the consistency of a compressed file and check whether the file has any errors;

-V: displays the compression ratio of the original file/compressed file;

-#: Compression level.-1 is the fastest, but the compression ratio is the worst.-9 is the slowest, but the compression ratio is the best! The default value is-6.

 

2. zcat file name .gz

Directly view the File Content Without decompression

 

3. bzip2 compressed to bzip2

Bzip2 [-cdkzv #] File Name

Options and parameters:

-C: output the data generated during the compression process to the screen!

-D: extracted Parameters

-K: Keep the source file without deleting the original file.

-Z: Compression Parameters

-V: displays the compression ratio of the original file/compressed file;

-#: Compression level,-9 is the best,-1 is the fastest!

 

4. bzcat file name .bz2

Directly view the File Content Without decompression

 

5. tar packaging command

Options and parameters:

-C: Create a package file

-T: Check the file names contained in the package.

-X: unpack or decompress the package. You can use-C to uncompress the package in a specific directory.

-J: Use bzip2 to compress or decompress the file. The file name is * .tar.bz2.

-Z: compression/Decompression using gzip support: the file name should be * .tar.gz.

-V: displays the file name being processed during compression/decompression!

-F filename: name of the file to be processed immediately after-f! -F is recommended to write an option separately!

-C Directory: This option is used for decompression. to decompress the package in a specific directory, you can use this option to select "Unzip.

-P: retains the original permissions and attributes of backup data. It is often used in backup (-c) important configuration files.

-P: retain the absolute path, that is, allow the backup data to contain the root directory;

-- Exclude = FILE: do not pack the FILE during compression!

 

Use Case:

Compression: name of the file or directory to be compressed by tar-jcv-f filename.tar.bz2
Query: tar-jtv-f filename.tar.bz2
Decompress: tar-jxv-f filename.tar.bz2-C directory to be decompressed

Extract only a specific file: tar-jxv-f/root/etc.tar.bz2 etc/shadow

 

Iii. System Backup and Restoration

1. You can use dump to back up the file system.

Dump supports the backup of the entire file system or a single directory. When backing up a single file system, you can perform hierarchical backup. During backup, you can use a mount point or device file name.

When you back up a directory, all the backup data must be under this directory. Only full backup is supported and hierarchical backup is not supported.

 

Dump [-Suvj] [-level] [-f backup file] data to be backed up

Options and parameters:

-S: only list the disk space required for data backup;

-U: record the dump time to the/etc/dumpdates file;

-V: displays the dump file process;

-J: added support for bzip2! Compress data. The default bzip2 compression level is 2.

-Level: the level from-0 ~ -9 a total of 10 levels;

-F: A bit similar to tar. The files subsequently generated can also be connected to/dev/st0 device file names.

-W: Have dump-Set partition backups been listed in/etc/fstab?

 

2. Use restore to restore the system.

 

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.