22.2 "Linux learning is not difficult" archive and compress (2): Use and management of tar packages
Using the tar command, you can save many files together to a separate tape or disk archive, and you can restore the required files separately from the archive.
Command syntax:
tar [options] [file | directory]
The meanings of the options in the command are as shown in the table.
Option option meaning
-C Create a new archive file
-A add tar file to archive
-R append file to end of archive
-T lists the contents of the archive to see which files have been backed up
-U only appends files that are newer than the copies in the archive
-X releasing files from the archive file
-F using an archive file or device
-K saves the file that already exists. Overwrite when you encounter the same file when restoring a file
-M create multi-volume archive for storage on several disks
-V detailed report on tar processing information
-C < directory > extract to a specific directory
-Z Archive via gzip filter
-J Filtering Archives via bzip2
-j via XZ Filter Archive
-A Use the archive suffix name to determine the compression program
Example: Archive/root/abc directory, generate file as/root/abc.tar.
[Email protected] ~]# tar cvf/root/abc.tar/root/abc
Tar: Remove the Beginning "/" from the member name
/root/abc/
/root/abc/a
/root/abc/b
/root/abc/c
Example: View the contents of a/root/abc.tar archive file.
[Email protected] ~]# tar Tvf/root/abc.tar
Drwxr-xr-x root/root 0 2015-12-23 12:24 root/abc/
-rw-r--r--root/root 0 2015-12-23 12:24 root/abc/a
-rw-r--r--root/root 0 2015-12-23 12:24 root/abc/b
-rw-r--r--root/root 0 2015-12-23 12:24 root/abc/c
Example: Unpacking the archive file/root/abc.tar.
[Email protected] ~]# tar Xvf/root/abc.tar
root/abc/
root/abc/a
Root/abc/b
Root/abc/c
This article is an excerpt from the "Linux learning is not difficult" textbook, this is the most practical, theoretical practice and emphasis on the introduction of Linux teaching materials.
"Linux learning is not difficult" archive and compress (2): Use and management of tar packages