Linux Command Learning Series 13-gzip,tar command

Source: Internet
Author: User
Tags gz file

Previous section review:

1. Locate command

2. Whereis,which command

Job: Create a file myfile.txt, find it with locate, and find the CD command with which and Whereis, respectively

Touch MyFile.txt

Locate MyFile.txt

UpdateDB

Locate MyFile.txt

Whereis CD

which CD


1. gzip/gunzip

Gzip is used to compress files in place, it is simple to use, for example, we want to compress the messages file under/var/log, can be used directly with GZIP messages

You can find that the messages file does not exist, one more messages.gz file

At the same time we use Gzip messages.gz–l to view the zip file details

We can see that the compression ratio is 87.3% or quite impressive.

To unzip a newly compressed file, you can use Gunzip

Gzip can only be used to compress files, cannot compress directories, can use GZIP–H to see more parameter description


2. tar

The tar command can not only package files but also package directories, and it can also use the compression feature of Gzip.

For example, the most general usage of this command, such as packing the log directory, can be used

TAR–ZCVF Log.tar.gz/var/log

The parameters here, Z, are compressed with gzip, c means the file is created, v indicates the compressed file is displayed, and F indicates the use of the filename.

To unzip the file you just created, use TAR–ZXVF Log.tar.gz–c/tmp/log


Job: Compress the Lastlog file under/var/log with gzip, then unpack it with gunzip, and pack the ETC directory into the TMP directory with tar


Follow the public number "kick genius" for a full video + graphics tutorial

Linux Command Learning Series 13-gzip,tar command

Related Article

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.