Get the App
SLTechnology News&Howtos  ›  Servers  › 

Introduction to the usage of tar command under Linux

Shulou Source: shulou.com Published: 2022-06-01 15:14:32 10月12日 Update

This article mainly introduces "introduction to the usage of tar command under Linux". In daily operation, I believe many people have doubts about the introduction of tar command under Linux. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "introduction to the usage of tar command under Linux". Next, please follow the editor to study!

Tar is the most commonly used packaging and compression tool under Linux. It plays a role similar to that of WinZip or WinRAR under Windows in Linux. The following are the common command parameters of the tool and examples of its application:

Main commands:

-c create package

-x unpack

-t list the contents of the package

-r add files to the specified package

-u update the files in the package

Optional commands:

-j use bzip2 for compression or decompression when creating or unpacking a package

-z use gzip to compress or decompress when creating or unpacking a package

-Z use compress to compress or decompress when creating or unpacking a package

-f followed by the specified package file name

-v displays the packing / unpacking process

-C specifies the path after unpacking

For example:

Tar-czf tmp.tar.gz / tmp zips the "/ tmp" directory to tmp.tar.gz

Tar-xzf tmp.tar.gz-C / home unpack the tmp.tar.gz package to the "/ home" directory

Tar-t tmp.tar.gz to view file information in the tmp.tar.gz package

Tar decompression problem

As shown below, an error such as "gzip: stdin: not in gzip format" was encountered when extracting the file using tar-zxvf:

The code is as follows:

[root@DB-Server tmp] #

[root@DB-Server tmp] # tar-zxvf Percona-XtraBackup-2.2.12-r8726828-el5-x86_64-bundle.tar

Gzip: stdin: not in gzip format

Tar: Child returned status 1

Tar: Error exit delayed from previous errors

Finally found that this compression package is not compressed in gzip format, so there is no need to add z parameters, shame!

The code is as follows:

[root@DB-Server tmp] # tar-xvf Percona-XtraBackup-2.2.12-r8726828-el5-x86_64-bundle.tar percona-xtrabackup-2.2.12-1.el5.x86_64.rpmpercona-xtrabackup-debuginfo-2.2.12-1.el5.x86_64.rpmpercona-xtrabackup-test-2.2.12-1.el5.x86_64.rpmYou have new mail in / var/spool/mail/root [root@DB-Server tmp]

At this point, the study of "introduction to the usage of the tar command under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Commands files learning code parameters tools commonly used more directories questions help practical next no information content file names articles methods useful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology Xiaomi MariaDB Docker