Linux tar command detailed

Source: Internet
Author: User
Tags bz2 rar uncompress

1. With the tar command, you can package a whole bunch of files and directories into a single file, which is useful for backing up files or combining several files into one file for easy network transmission.


2. Tar command parameters

-A or--catenate: Add files to the existing backup file;

-B: Set the chunk size;

-C or--create: Create a new backup file;

-C < directory;: This option is used for decompression, which you can use to decompress in a specific directory.

-D: Record file differences;

-X or--extract or--get: Restore files from the backup file;

-T or--list: Lists the contents of the backup file;

-Z or--gzip or--ungzip: The backup file is processed by the gzip command;

-Z or--compress or--uncompress: The backup file is processed by compress instruction;

-f< backup files > or--file=< backup files;: Specify backup files;

-V or--verbose: Displays the instruction execution process;

-R: Add files to files that have been compressed;

-U: Add changed and existing files to a compressed file that already exists;

-J: Support bzip2 Extract files;

-V: Show operation process;-L: File system boundary setting;

-K: Keep the original file without overwriting;

-M: Reserved files are not overwritten;

-W: Confirm the correctness of the compressed file;

-P or--same-permissions: Restore files with the original file permissions;

-P or--absolute-names: The filename uses an absolute name and does not remove the "/" number before the file name;

-N < date format > or--newer=< date time;: Save only files updated with the specified date to the backup file;--exclude=< template style;: Exclude files that conform to the template style.


3. Tar Command example

(1). Tar
Unpacking: TAR-XVF Filename.tar
Package: TAR-CVF Filename.tar directionname
---------------------------------------------

(2) . Tar. Z
Decompression: TAR-ZXVF Filename.tar.z
Compression: TAR-ZCVF filename.tar.z directionname

---------------------------------------------

(3) . tar.gz
Decompression: TAR-ZXVF FileName.tar.gz
Compression: TAR-ZCVF FileName.tar.gz directionname

---------------------------------------------

(4). tar.bz2
Decompression: TAR-JXVF FileName.tar.bz2
Compression: TAR-JCVF FileName.tar.bz2 directionname

---------------------------------------------

(5). tar.tgz
Decompression: TAR-ZXVF FileName.tar.tgz
Compression: TAR-ZCVF FileName.tar.tgz FileName

---------------------------------------------

(6) . tgz
Decompression: TAR-ZXVF filename.tgz


3. Other commands

(1). gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz

Unzip:gzip FileName

---------------------------------------------
(2). bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName
---------------------------------------------
(3). BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
---------------------------------------------
(4). Z
Decompression: uncompress filename.z
Compression: Compress FileName
---------------------------------------------
(5). zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip DirName
---------------------------------------------
(6). rar
Decompression: Rar-a Filename.rar
Compression: Rar-e Filename.rar


4. References

http://man.linuxde.net/sub/file Compression and decompression


This article is from the "cattle on the Road" blog, please be sure to keep this source http://9083895.blog.51cto.com/9073895/1877074

Linux tar command detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.