First, Introduction
The tar command is used to package one or more files and directories. Compress and decompress files. Tar itself does not have the compression function, is called the compression function implementation.
Ii. Methods of Use
Syntax: tar [options] [file] option:-C Create new compressed file-D record file difference-R add file to already compressed file-u add changed and existing file to already existing compressed file-X extract file from compressed file-t display compressed file content-Z Support gzip Unzip files-j support bzip2 unzip file-Z support compress unzip file-V display operation Process-K keep the original file does not overwrite-m reserved file not overwritten-W Confirm compressed file correctness
Third, the case
1. Package The root directory and save it as Root.bak.tar
[Email protected] ~]# TAR-CF Root.bak.tar /root/
2. Package The boot directory and compress it to boot.bak.gz
[[email protected] ~]# TAR-ZCF boot.bak.gz/boot[[email protected] ~]# ls-lh boot.bak.gz-rw-r--r--1 root root 32M February
23 15:56 boot.bak.gz
3. Package The boot directory and compress it to boot.bak.bz2
[[email protected] ~]# TAR-CJF boot.bak.bz2/boot/[[email protected] ~]# ls-lh boot.bak.bz2-rw-r--r--1 root root 32M 2 Monthly 15:58 boot.bak.bz2
4. Unzip the file to the specified directory
[Email protected] ~]# tar-xf boot.bak.bz2-c/tmp/[[email protected] ~]# ls/tmp/boot
The TAR command for Linux