The most common compressed packages are tar, GZ, bz2.
Zip and RAR are mainly from windows.
Package Multiple files into one file. The general size is not changed. This is called packaging.
Reduce the size of a file, which is called compression.
There are two types of compression: lossy compression and lossless compression. The standard is to determine whether compression is the same as compression before compression.
MP3, JPG, and RM formats are lossy compression because compression ratio is important.
Lossless compression is mainly used to deal with binary files, documents, and other data. Data inconsistency is not allowed, which generally sacrifices the compression rate.
In Linux, files do not have the suffix name concept, and the dot is just a separator. It is not very dependent on the suffix name in windows.
Packaging command: Tar c v f x z J
C: Create a compressed package
V: variable allows you to view detailed packaging information.
F: file generation File
X: extract Extract
Z: gzip.
GZ and bz2 are both compression commands, and bz2 has a relatively high compression ratio.
The 7z command is powerful and supports all the preceding compression formats.
. Z commands are commonly used for compression and decompression. (Note that Z is capitalized ).
First use the tar tool to package multiple files into one file, the size will not change, and then use the GZ compression to generate the .tar.gz file.
Or use tar and bz2 for compression.
Explain the following command sequence:
Ls # view files and folders in the current directory
CP/var/log/*. # copy all files in the/var/log directory to the current working directory.
Du-SH # view the space occupied by the current directory
Tar CVF dest.tar * # package all files in the current directory, generate files, and print detailed information
Ls-l dest.tar
Ls-l dest.tar-H
After running the gzip command, dest.taris deleted, and only dest.tar.gz is left, which has been compressed.
Ls dest.tar.gz-lH #
Gunzip dest.tar.gz # decompress the file. Note that after running this command, dest.tar.gzwill be replaced by dest.tar.
Ls-lH dest.tar
Bzip2 dest.tar # compress again using the Bzip2 command.
Ls-l dest.tar.bz2-H
Tar xvfj dest.tar.bz2 # unzip the file. Note that the J switch will exempt you from calling bz2-D to decompress the file. Z switch will exempt you from calling gzip-D.
Ls dest.tar.bz2
Rm dest.tar.bz2
Zip dest2.zip * package and compress all files in the current directory. Note that zip is equivalent to packaging and compressing two commands.
Unzip dest2.zip