Commands for compressing and packaging CentOS file systems

Source: Internet
Author: User
Tags uncompress

Commands for compressing and packaging CentOS file systems

1. file compression principle: currently, bytes units are used in computer systems for measurement. However, in fact, the smallest unit of measurement in computer systems is bits, we also know that 1 byte = 8 bits. That is, each byte contains eight spaces, and each space can be 0 or 1. Therefore, if we want to record the number 1, the other seven spaces will be wasted. The compression technology is to use some algorithms to Remove unused controls to reduce the space occupied by files. Another compression technique is used to record duplicate data. For example, 1111 ...... When a total of 100 1 s, the compression technology will record 100 1 s instead of actually storing 100 1 s.

2. file suffixes and compression methods:

1) *. Z: Files compressed by the compress Program

2) *. gz: Files compressed by the gzip Program

3) *. bz2: Files compressed by the bzip2 Program

4) *. tar: The data packaged by the tar program has not been compressed.

5) * .tar.gz: Files packaged by the tar program and compressed by gzip

6) * .tar.bz2: Files packaged by the tar program and compressed by bzip2

3. Common linux compression commands are gzip and bzip2. As for compress. Gzip is a command developed by the GNU program, which has replaced compre. Later, GNU developed bzip2, a better compression command. However, these commands can only compress and decompress an object. Therefore, each compression and decompression requires a large number of files. Therefore, you can use tar for packaging. Tar packs many files into one file or even a directory. Only tar is a packaging function.

4. compress [-rcv] file or directory: The ncompress software must be installed for commands that are very old. Gzip can uncompress the compressed files.

1)-r: It can be compressed together with files in the directory.

2)-c: output the compressed data to the screen. You can save the compressed data to the specified file through> filename. The source file still exists.

3)-v: The compressed file information and compressed file name changes can be displayed.

By default, the source file will be replaced by the compressed file.

Uncompress file. Z: Decompress the file, remove the suffix, and restore it to the source file.

5. gzip [-cdtv #] File Name; zcat file name .gz: Compressed and decompressed file, parameter:

1)-c: displays compressed data on the screen and can be processed through data flow guidance.

2)-d: Compression Parameters

3)-t: it can be used to check the consistency of a compressed file and check whether the file has any errors.

4)-v: displays the compression ratio of the original file/compressed file.

5)-#: the 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. Enter a number #.

The directive compresses the file into a file name suffixed with .gz, and the source file no longer exists. In addition, the files compressed by this command can also be decompressed by winrar software under ipvs.

Zcat command can read gzip compressed files

6.bzip2 [-cdkzv #] file name, bzcat file name. bz2: provides a better compression solution than gzip. parameters:

1)-c: output the data generated during the compression process to the screen.

2)-d: extracted Parameters

3)-k: Keep the source file without deleting the original file.

4)-z: Compression Parameters

5)-v: displays the compression ratio of the original file/compressed file.

6)-#: The same as gzip, the compression ratio parameter is calculated.-9 is the best, and-1 is the fastest.

Bzcat: You can also read compressed files.

7. tar [-jz] [cv] [-f file name] filename: Package and compress

Tar [-jz] [TV] [-f created file name]: View File Name

Tar [-jz] [xv] [-f created file name] [-C Directory]: Decompress

Parameters:

1)-c: Create a package file. You can use-v to erase the name of the package in the process.

2)-t: check which file names are included in the package file

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

Note:-c,-t, and-x cannot appear in a command at the same time.

4)-j: Use bzip2 to compress/decompress the file. At this time, the file name is * .tar.bz2.

5)-z: compression/Decompression using gzip support: the best archive name is tar.gz.

6)-v: displays the file name being processed during compression/decompression.

7)-f filename: name of the file to be processed immediately after-f

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

9)-p: retains the original permissions and attributes of backup data, which is often used to back up important configuration files

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

11) -- exclude = FILE: Do not package files during compression.

Command package:

Compression: name of the file or directory to be compressed by tar-jcv-f filename.bar.bz2

Query: tat-jtv-f filename.tar.bz2

Compressed: tar-jxv-f filename.tar.bz2-C directory to be decompressed

The preceding j position can also be changed to-z, which indicates the gzip compression mode.

8. dump [-Suvj] [-level] [-level] [-f backup file] file to be backed up; dump W: parameter,

1)-S: only list the space required for data backup to be completed.

2)-u: record the dump time to the etc/dumpdates file.

3)-v: displays the dump file process.

4)-j: added the support of bzip2 to compress data. The default value is bzip2. The compression level is 2.

5)-level: grade, from-0 ~ -8

6)-f filename: The file generated later

7)-W: List whether the dump-configured partition in etc/fstab has been backed up.

9. restore-r [-f dumpfile]: restores the entire file system. parameters:

1)-t: This mode is used to view the important data contained in the dump backup file.

2)-C: This mode can compare the data in dump with the actual file system.

3)-I: In interactive mode, only some files can be restored and used in the dump directory.

4)-r: A mode for restoring the entire file system. It is used to restore the dump backup for the file system.

5)-h: View inode, file system label, and other information in the complete backup data.

6)-f: the dump file you want to process will be followed.

7)-D: Works with-C to check whether the mount point to be followed is different from that in dump.

10. mkisofs [-o image file] [-rv] [-m file] file to be backed up... [-V vol]-graft-point isodir = systemdir ..., Parameters:

1)-o: the file name of the image you want to generate

2)-r: Generate Unix/Linux archive data through Rock Ridge and record more information.

3)-v: displays the ISO creation process.

4)-m file:-m indicates that the file is excluded, and subsequent files are not backed up to the image file.

5)-V vol: Creates a Volume, something like the CD title that Windos sees in the File Manager.

6)-graft-point: graft has the meaning of transferring or porting,

11. cdrecord: CD burning command

12. dd-if = inputfile of = outfile bs = blocksize count = number: parameter,

1) if: the file to be backed up, which can also be a device

2) of: the backup target file or device

3) bs: the size of a planned block. If not specified, the default value is 512 bytes.

4) count: the number of bs.

13. cpio-ovcB> [file | device] backup; cpio-ivcdu <[file | device] restoration; cpio-ivct <[file | device] view, parameters:

1)-o: output data copy to the file or device

2)-B: Increase the preset Blocks size to 5120 bytes. the preset size is 512 bytes, which allows you to access large files more quickly.

3)-I: copy data from a file or device to the System

4)-d: automatically create a directory

5)-u: automatically overwrites older files

6)-t: the file or device content created in cpio can be viewed with the-I Option

7)-v: enables the file name in the stored procedure to be displayed on the screen.

8)-c: a newer portable format Storage Method

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.