Gzip, bzip2, tar, zip command usage details 1. gzipgzip is a GNU compression program. It only compresses a single file. The basic usage is as follows: after the $ gzip filenameprogram is executed, the file name is changed to filename.gz, And the size is usually smaller than that of the original file. Then, the program does not create a new file filename.gz, but changes filenameinto filename.gz. This basic usage considers the balance between the compression time and the size of the compressed file (Note: It takes more time to make the compressed file smaller ). To obtain the minimum file size (maximum compression), you can use the following usage: $ gzip-9 filename to obtain the minimum file size that gzip can compress, but it takes a longer compression time. The smaller the number, the faster the compression, and the smaller the compression ratio. Decompress the gzip files. Two commands can be used, but they are actually the same program. The gzip program can recognize the following extensions of compressed files:. gz,-gz,. z,-z,. Z, and-Z. You can run the following command: $ gunzip filename.gz or $ gzip-d filename.gz. after using the authorization command, filename.gzwill be decompressed and replaced with filename. GZ. 2. bzip2bzip2 is another option for the compression program in Slackware Linux. Its compression algorithm is different from that of gzip. Compared with gzip, the main advantage of bzip2 is the size of the compressed file. For the same file, the size of bzip2 after compression is almost always smaller than the size of gzip. In some cases, this gap may be quite large. The disadvantage of bzip2 is that it consumes more CPU usage and compression time than gzip. Examples. $ bzip2 filename $ bunzip2 filename.bz2 $ bzip2-d filename.bz2 $ bzip2-9 filename-c: output the data produced by the compression process to the screen. For example. config uses the best compression ratio and retains the original file [root @ linux tmp] # bzip2-9-c man. config> man.config.bz2 bzcat reads the content in the bz file and displays it on the screen. The bz file still exists. For example, bzcat filename.bz2 3. tartar is a GNU tape archiving program. It can package several files or directories into one file. This feature allows us to compress the entire directory tree, while gzip and bzip2 alone cannot. A.tar.gz first packages some files with tar and then compresses them with gzip. A.tar.bz2 first packages some files with tar and then compresses them with bzip2. Decommission a tar file: $ tar xzvf filename.tar.gz or $ tar-xvzf filename.tar.gz $ tar xjvf filename.tar.bz2 or $ tar-xvjf filename.tar.bz2-x indicates file extraction. It tells tar to separate the packaged files and restore them to the status before packaging. -V is verbose, indicating detailed details. Add this parameter so that the program can list each file that is decompressed. -Z tells tar to first run gunzip to decompress the file. -J tells tar to run bunzip to decompress the file first. -F indicates the file name to be processed by the specified tar. Note that tar will put the file to the current directory. So if you want to extract a file in the/tmp directory to your home directory, there are some options: select one and copy the file to the home directory, then unpack $ cd $ HOME $ cp/tmp/filename.tar.gz. $ tar-xvzf filename.tar.gz select 2 and specify the path of the file to be decompressed. $ cd $ HOME $ tar-xvzf/tmp/finename.tar.gz select 3, use the-C parameter to specify the path for storing files after unpacking $ cd/$ tar-xvzf/tmp/filename.tar.gz-C $ HOME tar file packaging: $ tar-czvf filename.tar.gz. $ tar-cjvf filename.tar.bz2. /src/-c is to tell tar to create a package file-z is to compress the package file through the gzip program. -J is to compress the packaged files through the bzip2 program. -F indicates the file name processed by the specified tar. Filename.tar.gz is the name of the file to be created. The "." Or "./src/" at the end of the command line specifies the tar package directory, including the Directory and all files/folders under the directory. 4. the zip file compression program is called zip, and the decompression program is called unzip. Linux supports this command. $ Zip foo * This line creates a zip file foo.zipthat contains all the files in the current directory. Zips will automatically add the. zip extension name. Add the parameter-r so that zip can add all the folder directories under the current directory to the zip file: $ zip-r foo * decompress the file: $ unzip foo.zipto decompress all the files and folders in foo.zip.