File and file system compression and packaging Basic compression command
1. Gzip is the most widely used compression command. Bzip2 is designed to replace gzip and provide a better compression ratio.
During compression, Bzip2 is more powerful and can save the original file, while gzip cannot.
Gzip [-cdtv #] File Name
Bzip2 [-cdkzv #] File Name
2. For compressed text, we can also view the content of the compressed file through zcat and bzcat.
3. Packaging command: Tar
The simplest way to use tar is as follows:
Compression: name of the file or directory to be compressed by tar-JVC-F filename.tar.bz2
Query: tar-jtv-F filename.tar.bz2
Decompress: tar-jxv-F filename.tar.bz2-C directory to be decompressed (-C can use this parameter to decompress files in a specific directory)
How to decompress a single file: eg: tar-jtv-F/root/etc.tar/bz2 | gerp 'shadow'
Grep is used to select keywords.
4. Full backup tool: Dump
Dump has powerful functions. In addition to backing up the entire file system, you can also set a level.
When you back up a file system, level0 is used for the first backup. This level is full backup. During the second backup, the data in the real-time file system is different from level0, level1 only backs up changed files after comparing the differences between the current file system and level0. This is classified backup.
If the dump Backup Directory is used, the backup data must be under this directory and only level0 can be used. That is, only full backup is supported, and the U parameter is not supported.
/Etc/dumpdates the level backup time record file.
5. Restore backup data: Restore
Backup files are important data that can be recovered in an emergency, so we should know how to recover them. Dump resumes using the restore command.
6. CD Writing Tool
First, create an image file: mkisofs
CD burning tool: cdrecord
Reference Book p265 for details
7. Other common compression and backup tools
DD, a very powerful backup tool, such as: dd If =/etc/passwd of =/tmp/passwd. Back
Eg: dd If =/dev/HDC of =/tmp/MBR. Back BS = 512 COUNT = 1; back up MBR and partition tables in the first sector
Cpio can back up everything, including device files. However, cpio has a problem. It does not take the initiative to find files for backup. Reference books p270
Important Review