Compression Tools :
1 "zip,unzip
Format: #zip compressed file name original file name
1. Recursively compress files in a directory and directory:
#zip-R Var-log-dir/var/log
2. Compress multiple files in the directory:
#zip var-log-files/var/log/* This method does not recursively compress files under subdirectories.
3. Review the details during the decompression process:
#unzip-V Compressed file
4. View the list of files in the compressed file without being pressed:
#unzip-L Compressed files
5. Check the integrity of the compressed file:
#unzip-T Compressed files
6. Unzip to the specified path:
#unzip compressed file-D path
7. Specify the compression ratio:
#zip-# Compressed file name original file name
The ZIP command provides 10 levels of compression:
O Level 0 is the lowest level, do only archive, do not compress
O Level 1 Low compression rate, but very fast
O Level 6 is the default compression level
O Level 9 has the highest compression rate, but it takes a lot of time, except for large files, we generally recommend using Level 9
Password protection for 8.zip files:
Use the P option of the zip command to encrypt the zip file
#zip-P mysecurepwd var-log-protected.zip/var/log/*
Using the above options for background work in shell scripts is a good choice. But when you use interactive command lines, you don't usually want your password to be visible in the history. So, this is the time to use the following e-option to set the password.
# ZIP-E var-log-protected.zip/var/log/*
Enter Password:
Verify Password:
Updating:var/log/acpid (deflated 81%)
Updating:var/log/anaconda.log (deflated 79%)
When you want to extract a password-protected compressed file, you will be asked to enter a password.
# Unzip Var-log-protected.zip
Archive:var-log-protected.zip
[Var-log-protected.zip] var/log/acpid Password:
2 " gzip, gunzip = gzip-d, zcat(View compressed file contents)
Suffix:. gz
-C: The compressed result is sent to standard output , you can use redirection to save it as a compressed file, thereby preserving the original file;
bzip2, bunzip2 = bzip2-d, bzcat
Suffix:. bz2
-K option: Retain the original file after compression and retain the original compressed file after decompression
xz, unxz = xz-d, xzcat
Suffix:. xz
-#: Specify compression ratio, 1-9
3 "Archive tool:tar
tar [options] filename.tar.gz original file
tar [options] filename.tar.bz2 original file
tar [options] filename.tar.xz original file
-C: Create an archive
-X: Expand Archive
-T: View archived file list directly without pressure
-z:gzip
-j:bzip2
-j:xz
-zcf
-zxf
-jcf
-jxf
-jcf
-jxf
Note: the "-" option in front of the tar command can be omitted, in addition, the z,j,j of the option part can be omitted during decompression, and tar automatically calls the matching decompression tool according to the compressed file format.
Linux Compression Archive Tool