Quick introduction to linux compression and decompression aims to quickly learn about linux document compression and decompression. For details about a command, refer to man or google. Www.2cto.com GUN-zip (gz) compression: gzip testfile unzip: gunzip testfile.gz unzip decompress testfile.gz view: zcat testfile.gz unzip the content of testfile.gz. By default, GUN-zip deletes the source file. Bzip2 (bgz bz) compression: bzip2-z testfile plugin or: bzip2-c testfile> testfile2.bz2-c stdout, and decompress testfile.bz2 from ing to file: bzip-d testfile.bz2 View: bzcat testfile.bz2 compressed can be viewed in the Compressed Content of testfile.bz2 www.2cto.com tar (tar) tar-cvf/tmp/mytest.tar/home/testfolder # archive a directory tar-xvf/tmp/mytest.tar-c/home/testfolder # restore the archive tar.gz (tar.gz tgz) tar-cvzf/tmp/mytest.tar.gz/home/testfolder # compress and archive a directory (using g Zip-z) tar-xvzf/tmp/mytest.tar.gz # decompress the archive tar.bz2(tar.bz2) tar-cvjf/tmp/mytest.tar.bz2/home/testfolder # compress and archive a directory (using bzip2) tar-xvjf/tmp/mytest.tar.bz2 # decompress the archive and use the following two commands to replace gunzip/tmp/mytest.tar.gz tar-xvf mytest.tar-c/home/testfolder bzip2-d/tmp/ mytest.tar.bz2 tar-xvf mytest.tar-c/home/testfolder cpiols | cpio-ocv> .. /thisfolder. cpio calls all the current directories to the thisfolder directory under the parent directory. cpiocpio-icdv <thisfolde R. cpio: Release thisfolder. cpio in the parent directory. Decompress the cpio file cpio-idmv <filename. cpio can also decompress the imgfile: cpio-idmv <filename. imgcpio BACKUP command backup: cpio-ocvB> [file | device] Back up data to a file or device to restore: cpio-icduv <[file | device} restores data to the system. Common parameter:-o: copy data to a file or device-I: restore data from a file or device to the System-t: view the file or device content created by cpio-c: A new portable format storage-v: display the file name B During the backup process on the screen: Increase the preset blocks size to 5120 bytes. The default value is 512 bytes. This will speed up the backup.-d: automatically create a directory, in this way, the path cannot be found.-u: update. When a newer file is used to overwrite the old file cpio, cpio.gz is usually used with find and First decompress gunzip and then restore the document in cpio. RAR (rar -- rarlinux) compression: rar decompression: unrar zip compression: zip decompression: unzip compress (Z) compression: compress file or: compress-c file> file. Z decompress: compress-d file. z-d: extract parameter-r: It can be compressed together with files in the directory! -C: output compressed data to standard output, which can be redirected to file. z dd from the internet. Thanks to the original author, especially for the example of writing, it can speed up understanding. If = file input file name standard input indeed saves of = file output file name, standard output indeed saves ibs = n input block size, n Bytes (512 by default) obs = n output block size, n Bytes (512 by default) bs = n at the same time set the size of the input and output block cbs = n conversion buffer size files = n before the interruption to copy and convert n input file skip = n before the copy over n input block oseek = n. before copying, search for n iseeks from the output file. before copying, search for n seek blocks from the input file. = n is equivalent to oseek cono = ascic. The EBCDIC code is converted to ASCII 1. back up the local/dev/hdb disk to/dev/hdddd if =/dev/hdb of =/dev/hdd 2. back up full/dev/hdb data to the image file dd in the specified path if =/dev/hdb of =/root/image 3. restore the backup file to the specified disk dd if =/root/image Of =/dev/hdb 4. back up/dev/hdb full data, compress it with gzip, and save it to the specified path dd if =/dev/hdb | gzip>/root/image.gz 5. restore the compressed backup file to the specified disk gzip-dc/root/image.gz | dd of =/dev/hdb 6. the MBR information of the first 512 bytes starting from the backup disk is copied to the specified file dd if =/dev/hda of =/root/image count = 1 bs = 512 count = 1 block; bs = 512 indicates that the block size is 512 bytes. Recovery: dd if =/root/image of =/dev/hda 7. backup floppy disk dd if =/dev/fd0 of = disk. img count = 1 bs = 1440 k (Block Size: 1.44 MB) 8. copy the memory content to the hard disk dd if =/dev/mem of =/root/mem. bin bs = 1024 (specify the block size as 1 k) 9. copy the content of the cd to the specified folder and save it as cd. iso file dd if =/dev/cdrom (hdc) of =/root/cd. iso 10. step 1: Create a swap partition file with a size of 1024 MB: dd if =/dev/zero of =/swapfile bs = 262144 count = Step 2: change this file to a swap file: mkswap/swapfile Step 3: Enable this swap file: swapon/swapfile Step 4: edit the/etc/fstab file, Automatically load the swap file at each boot:/swapfile swap default 0 0 11. destroy disk data dd if =/dev/urandom of =/dev/hda1 Note: use random data to fill the hard disk and destroy data as necessary. 12. test the hard disk read/write speed dd if =/dev/zero bs = 1024 count = 1000000 of =/root/1 GB. file dd if =/root/1 GB. file bs = 64 k | dd of =/dev/null the command execution time output by the preceding two commands can calculate the Read and Write speeds of the hard disk. 13. determine the optimal disk size: dd if =/dev/zero bs = 1024 count = 1000000 of =/root/1 GB. file dd if =/dev/zero bs = 2048 count = 500000 of =/root/1 GB. file dd if =/dev/zero bs = 4096 count = 250000 of =/root/1 GB. file dd if =/dev/zero bs = 8192 count = 125000 of =/root/1 GB. file: Compare the command execution time shown in the preceding command output to determine the optimal Block Size of the system. 14. Fixed the hard drive www.2cto.com dd if =/dev/sda of =/dev/sda. When the hard drive is not used for a long time (for example, 1 or 2 years), magnetic fluxpoint will be generated on the disk. When the head reads these areas, it may encounter difficulties and may cause I/O errors. When this affects the first sector of the hard disk, the hard disk may be decommissioned. The preceding command may bring the data back to life. This process is safe and efficient. The difference between/dev/null and/dev/zero:/dev/null. The nickname is a bottomless pit. You can output any data to it. It can be used without support! /Dev/zero is an input device. You can use it to initialize files.