Tar
Used to package multiple files or directories into a large file
1. Pack/tmp and use BZIP2 compression
[Root@localhost ~]# TAR-CJVF./tmp.tar.bz2/tmp
Tar:removing leading '/' from member names
/tmp/
/tmp/man.config1.gz
/tmp/man.config
/tmp/. ice-unix/
/tmp/man.config9.gz
/tmp/man.config.bz2
-C Build Packaged files
-j use bzip2 to compress packaged files
-V Displays the file or directory being processed during package and unpack
The filename of the newly generated packaged file after the-F is followed
You can also use gzip to compress and then replace the-J parameter in the previous example with the-Z parameter. Of course, pack the compressed filename suffix to change to *.tar.gz because the bzip2 compression effect is better than gzip, so I usually use the-J parameter
When Tar is packaged, the "/" removal of the absolute path is usually the first "tar:removing leading"/"from member names" hint in the output. The advantage of this is that you can prevent you from solving a tar package by overwriting the file you are using directly. For example, you have packaged a/ETC catalog of tar packets from other hosts to this machine, if "/" is not removed, a solution package, because it is the absolute path will directly cover the/ETC directory of this machine, that tragedy. Of course you can also use the-P argument to keep this "/" but you must be careful when you unpack.
2. See what files are in the file that you just packaged
[Root@localhost ~]# TAR-TJVF tmp.tar.bz2
DRWXRWXRWT root/root 0 2013-08-17 14:16 tmp/
-rw-r--r--root/root 2332 2013-08-17 13:14 tmp/man.config1.gz
-rw-r--r--root/root 4940 2013-08-17 12:37 tmp/man.config
DRWXRWXRWT root/root 0 2013-08-17 12:36 tmp/. ice-unix/
-rw-r--r--root/root 2184 2013-08-17 13:15 tmp/man.config9.gz
-rw-r--r--root/root 2195 2013-08-17 12:37 tmp/man.config.bz2
-T View packaged files
3. Extract the packaged files into the/tmp/tar directory
[Root@localhost ~]# Mkdir/tmp/tar
[Root@localhost ~]# TAR-XJVF tmp.tar.bz2-c/tmp/tar
tmp/
Tmp/man.config1.gz
Tmp/man.config
tmp/. ice-unix/
Tmp/man.config9.gz
tmp/man.config.bz2
[Root@localhost ~]# Ll/tmp/tar
Total 4
DRWXRWXRWT. 3 root 4096 Aug 14:16 tmp
-X Unpack Package files
-C unzip the packaged files to the specified directory, and if not, the default is to extract to the current working directory
This is the basic usage of tar, so let's introduce a few of the slightly more advanced uses