The TAR command for Linux

Source: Internet
Author: User

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

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.