1. File Compression
File compression commands are divided into:
gzip : Compress files
gunzip : Extract Files
gzip-d: can also be used to extract files
bzip2 : Also compressed file
bunzip2 : Extract bzip2 Compressed files
Examples of the use of commands:
gzip Install.log : (Compress install.log files under current directory)
gunzip install.log.gz: (extract install.log.gz file)
gzip-d install.log.gz: (extract install.log.gz file)
bzip2 install.log : (Compress install.log files under current directory)
bunzip2 install.log.bz2: (extract install.log.bz2 file)
Of course, the file compression can also be extracted into a different file directory, "-C" parameter (refers to the contents of the file to be extracted to which file) for example:
gunzip install.log.gz-c/etc/doc (Here I will install.log.gz compressed files to be extracted to the ETC directory under the doc file) with bzip2 compressed file is the same, just add a-c parameter, and then specify the decompression path.
2. File Packaging
Package commands are divided into:
tar cvf: File packaging
tar rvf: Append files
tar xvf: Unpack files
There is the package after the file is compressed, the command is:
tar Cvfz(packaged and compressed, +z is an indication of gzip compression)
tar xvfz(unpack)
tar cvfj(packaged and compressed, +J is a compression that represents bzip2)
tar xvfj(unpack)
Examples of command usage:
# tar Cvf/tmp/root.tar . (Create a packaged file named Root.tar in the TMP directory, and then package all the files in the TMP directory, "." refers to all files)
# tar rvf/tmp/root.tar/etc/passwd (Add the passwd file in the ETC directory to the Root.tar package file)
# tar Xvf/tmp/root.tar (Unlock the Root.tar package in the TMP directory)
# tar cvfz/tmp/root.tar.gz . (Create a packaged compressed file named root.tar.gz in the TMP directory, and then package all files in the TMP directory and compress them)
# tar cvfj/tmp/root.tar.bz2 . (Create a packaged compressed file named ROOT.TAR.BZ2 in the TMP directory, and then package all files in the TMP directory and compress them)
Unpack the package only need to change CVF to XVF on line, also can add parameter-C to extract the compressed package to the specified directory, with the above said compressed file decompression same