Command line Summary of Linux compressed files

Source: Internet
Author: User
Tags gz file rar extension

reading of Linux compressed files

· *. Z Compress program compressed files;

· *.BZ2 bzip2 program compressed files;

· *.gz gzip program compressed files;

· *.tar the TAR program to package the data, and has not been compressed;

· *.tar.gz Tar program packed archives, which are compressed by gzip!

· *.zip Zip Program compressed file

· *.rar rar program zip file

Compress compressed Files

[email protected]/root]# Cp/etc/man.config/root
[email protected]/root]# compress man.config //compression Man.config this file
[email protected]/root]# compress-d man.config.z //-d Unzip this file
[email protected]/root]# uncompress man.config.z //Unzip this file

When you compress with compress, if you do not release other parameters, then the original file will be later *. Replaced by Z!

gzip Compressed files and Zcat

[email protected]/root]# gzip [-d#] filename <== compression and decompression
[email protected]/root]# zcat filename.gz <== Read Compressed file contents
Parameter description:
-D: Unzip the Parameters!

-R: Recursively handles all files and subdirectories under the specified directory
-#: Compression level, 1 most bad, 9 best, 6 is the default value!

[email protected]/root]# gzip Man.config //will produce man.config.gz this file

[email protected]/root]# zcat man.config.gz //will read out the contents of Man.config

[Email protected]/root]# gzip-d man.config.gz
[email protected]/root]# gunzip man.config.gz
Unzip, generate man.config this file

[email protected]/root]# gzip-9 man.config //Compression testing this file with maximum compression ratio!

[email protected]/root]# gzip-r filename.gz file1 file2 file3/usr/work/school
The contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) are compressed and then placed in the filename.bz2 file.

Bzip2 Compressed files and Bzcat

[email protected]/root]# bzip2 [-dz] filename <== compression decompression Instruction
[email protected]/root]# bzcat filename.bz2 <== Read compressed file contents instruction
Parameter description:
-D: Unzip the meaning!
-Z: Compression means!
Example:
In the same way, we've just copied the/root/man.config file as an example.
[email protected]/root]# bzip2–z Man.config
[email protected]/root]# Bzcat man.config.bz2
[Email protected]/root]# bzip2–d man.config.bz2
[email protected]/root]# bunzip2 man.config.bz2

[email protected]/root]# bzip2 filename.bz2 file1 file2 file3/usr/work/school

The contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) are compressed and then placed in the filename.bz2 file.

Tar Compressed Files

[email protected]/root]#tar [-ZXCVFPP] filename
[email protected]/root]#tar-n ' yyyy/mm/dd '/path-zcvf target.tar.gz source
Parameter description:
-Z: Do you have the properties of gzip at the same time?
-x: Unlock a compressed file parameter command!
-T: View the files inside the Tarfile!
-C: Create a parameter directive for a compressed file
-V: Files are displayed during compression!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" Just right!
-P: The original attribute of the original file is used (the attribute will not change according to the user)
-P: Absolute path can be used
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
--exclude file: In the process of compression, do not package file!
Example:
[email protected]/root]#TAR-CVF Directory.tar Directory

Package directory consolidation into one file only

[email protected]/root]# TAR-ZCVF directory.tar.gz Directory
In addition to packaging the directory, the gzip compression

[email protected]/root]# TAR-ZCVF filename.tar.gz/home/test/*
Package the files in this directory/home/test/and compress them into a filename.tar.gz file.

[email protected]/root]# tar-jcvf/tmp/etc.tar.bz2/etc <== is packaged to bzip2 compressed

[email protected]/root]# TAR-XVF Directory.tar
To unpack the tar, be aware that there is no gzip (. Tar instead of. tar.gz), so just use –XVF! No need to add Z, otherwise it will show a problem!

[email protected]/root]# TAR-ZXVF directory.tar.gz
This is the result of compression with Gzip Plus! So need to add –z yo!

[email protected]/root]# TAR–ZTVF directory.tar.gz
This t can be used to view the archive information in tar! Without having to untie him!

[email protected]/root]# TAR-ZCVPF home.tar.gz/home
The file in the compressed file is the absolute path.
Note that when you use this p parameter, do not add p after F, because
After F to immediately answer the file name!

[email protected]/root]# tar-n ' 2002/06/25 '-ZCVF home.tar.gz/home
The above is that in the home/home directory, more than 2002/06/25 of new files will be packaged into home.tar.gz this file!

[email protected]/root]# TAR-ZCVF host.tar.gz/--exclude/mnt--exclude/proc
The above means that all the data from the root directory is packaged in the host.tar.gz file, but/mnt and/proc are not packaged!

[email protected]/root]# TAR-CVF-Home | tar-xvf-
The above means "home/home" after packaging, directly extracted under the/root! Hey No need to set up an intermediate file again! However, using the above syntax is best used for "absolute path", the comparison will not be a problem! This is a good way to avoid creating intermediate files!

zip and unzip compressed files

[email protected]/root]# zip-r myfile.zip./* //To compress all files and folders in the current directory into Myfile.zip files,-R for recursively compressing all files in subdirectories.

[email protected]/root]# zip-d myfile.zip smart.txt //deleting smart.txt files in compressed files

[email protected]/root]# zip-m myfile.zip./rpm_info.txt //Add rpm_info.txt files to Myfile.zip in compressed files

[email protected]/root]# unzip-o-d/home/sunny myfile.zip //extract myfile.zip files to/home/sunny/

rar Compressed Files

# TAR-XZPVF Rarlinux-3.2.0.tar.gz
# CD RAR
# make

This installs well, after installation has RAR and unrar these two programs, RAR is the compression program, Unrar is the decompression program. They have a lot of parameter options, for example, to illustrate their usage

# rar a All *.jpg

This command compresses all. jpg files into a RAR package named All.rar, which will automatically append the. rar extension to the package name.

# Unrar E All.rar

This command extracts all the files in the All.rar.

Most compressed packages are now in RAR format, so a RAR tool is required.

First download RAR 3.60 Beta 6 for Linux in http://www.rarlab.com/download.htm

I unzipped to/opt, will automatically build the RAR directory. This tool can be used directly without compiling.

Create the Bin directory under the $home directory.

Create a link in the bin directory. Ln-s/opt/rar/rar rar.

You can use RAR tools to compress and decompress. rar files. However, this tool is command mode, and the RAR operation under DOS is the same.

Command line Summary of Linux compressed files

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.