Linux compression and decompression tutorial

  

This article summarizes how to compress files under Linux and the decompression method of common compressed file formats. Some decompression software can support multiple compression package formats at the same time, so the decompression method below may not be unique. For detailed usage, you need to be able to view it by parameters such as -h. At present, Ubuntu and other system platforms are becoming more and more perfect, and the compression and decompression functions are also evolving to intelligence and interface. It is believed that in the near future, like WINDOWS, there is no need to memorize any compression and decompression commands.

First, compressed files

This is only compressed into tar and tar.gz format, example:

1, compress the current directory filename file into filename.tar

tar -cvf filename.tar filename

2, again compress filename.tar into gz format, get filename.tar.gz

gzip filename.tar

Using reminder symbolic link questions:

  • If the file contains symbolic links, compression with the UBUNTU integration tool may be problematic, it is recommended to use command line compression.
  • Use the tar -cvf command to compress .tar. By default, the symbolic link will be handled implicitly. The compressed package will not see the symbolic link, but it will be generated correctly when decompressed.
  • If you use the integration tool to compress to .tar.gz at a time, the default symbolic link seems to have problems. It is recommended to use the command line to compress it into .tar and then press it into .tar.gz
  • Use when decompressing Tar -xhvf or tar -zxhvf, properly decompress the package with symbolic link.

    Second, decompress the file

    Unzip the operation as follows, the decompression target is the current folder.

    1, unzip.tar.gz2

    bzip2 -d filename.tar.bz2

    tar -xhvf filename.tar

    If a symbolic link is used , be sure to use the -h parameter.

    2, decompress .gz,.tgz

    gunzip filename.gz

    gunzip filename.tgz

    3, decompress .tar.Z

    tar -xvZf filename.tar.Z

    4, extract .tar.gz,.tgz

    tar -xvf filename.tar

    tar -zxvf filename.tar.gz

    tar -zxvf filename.tgz

    Unzip Note:

    If the original compressed file has a symbolic link (link file), currently It seems that only the command can be decompressed (-h parameter). If you use the compressed file manager to extract it, you will lose the symbolic link (not studied in depth), but extracting the .tar file does not seem to lose the symbolic link, so if you encounter a missing symbolic link Or you can try the command line mode, other formats are similar.

    5. Unzip.rpm

    rpm2cpio filename.rpm |  Cpio -div

    6, unzip.zip

    unzip filename.zip

  • Copyright © Windows knowledge All Rights Reserved