Tar is the most common packaging and compression tool under Linux, which plays a role similar to WinZip or WinRAR under Windows in Linux. Here is the tool's common command parameters and application examples:
Main commands:
-C Create Package
-X Solution Package
-T list the contents of the package
-R to add files to the specified package
-U update files in package
Optional command:
-j when creating or unpacking a package using bzip2 for compression or decompression;
-Z use gzip to compress or decompress when creating or unpacking a package;
-Z uses compress for compression or decompression when creating or unpacking a package;
-F followed by the specified package filename;
-V Display Package/unpack process
-c Specifies the path after the package is extracted
For example:
TAR-CZF tmp.tar.gz/tmp the "/tmp" directory compression package for tmp.tar.gz;
Tar-xzf tmp.tar.gz-c/home The tmp.tar.gz package to the "/home" directory;
Tar-t tmp.tar.gz View the file information in the tmp.tar.gz package;
Tar decompression problem
As shown below, you encounter errors such as "Gzip:stdin:not in gzip format" When you extract files 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 package is not compressed with the GZIP format, so do not add Z parameter, 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]#