Linux packaging and compression tar common commands

        Packaging: Turn a large number of files or directories into one total file.
        Compression: Turn a large file into a small file through some compression algorithms. two steps.

        Many compression programs in Linux can only compress one file. When you want to compress a large number of files, you need to pack a large number of files into a package before compressing.

Command format:

        Compression: tar [parameter] [name of the file to be generated] [which files to pack and compress]
        Decompression: tar [parameter] [file to be decompressed]

parameter:

        -c Create a compressed file (only use -c, it is a packaging process, the generated file is often called a tar package, ending with .tar)
        -x Unzip the compressed file (cannot be used with -c)
        -t View the compressed package What files are in
        -z Compress or decompress with Gzip
        -j Compress or decompress with bzip2 (use -z or -j, compression process)
        -v Display the process of compression or decompression (some files are very large, it will take a lot of time to compress, If the process is not displayed, you may sometimes think that the system is stuck)
        -f target file name (especially important, it must be placed at the end of the parameter)
        -p retain the original permissions and attributes
        -C specifies the directory to extract to (C uppercase)

Common suffixes and decompression parameters in Linux

        *.tar uses tar -xvf
        *.tar.gz uses tar -xzf
        *.tar.bz2 uses tar -xjf
If the file is uploaded from the local, it will have the form of *.zip and *.rar *
        .zip use unzip
        *. rar use unrar e

To give a few examples:

        tar cf all.tar *.txt packs all files with suffix .txt and names the new file all.tar
        tar zcf all.tar.gz *.txt packs and compresses all files with suffix .txt, And name the new file all.tar.gz
        tar zcvf all.tar.gz *.txt Pack and compress all the files with the suffix .txt, and name the new file all.tar.gz, display packing compression the process of

        tar zxvf all.tar.gz decompress all.tar.gz and display the process of decompression

Guess you like

Origin blog.csdn.net/h360583690/article/details/127243713