Linux compression/decompression methods

Source: Internet
Author: User
Tags gz file uncompress

Linux compression/decompression methods

In linux, there are many compressed packages in a variety of formats, and the command line is not as convenient as in Windows. Sometimes, when extracting files, the command will suddenly be forgotten, fcbu.com collects the decompression methods and Packaging Commands for all basic file formats. for more information, see:

. Tar
Unpack: tar xvf FileName.tar
Package: tar cvf FileName.tar DirName
(Note: tar is only packaged and has not been compressed !)
---------------
. Gz
Decompress 1: gunzip FileName.gz
Decompress 2: gzip-d FileName.gz
Compression: gzip FileName

.Tar.gz and. tgz

Decompress: tar zxvf FileName.tar.gz
Compression: tar zcvf FileName.tar.gz DirName
---------------
. Bz2
Decompress 1: bzip2-d FileName.bz2
Decompress 2: bunzip2 FileName.bz2
Compression: bzip2-z FileName
.Tar.bz2
Decompress: tar jxvf FileName.tar.bz2 or tar-bzip xvf FileName.tar.bz2
Compression: tar jcvf FileName.tar.bz2 DirName
---------------
. Bz
Extract 1: bzip2-d FileName. bz
Decompress 2: bunzip2 FileName. bz
Compression: Unknown
. Tar. bz
Decompress: tar jxvf FileName.tar. bz
Compression: Unknown
---------------
. Z
Decompress: uncompress FileName. Z
Compression: compress FileName
. Tar. Z
Decompress: tar Zxvf FileName.tar. Z
Compression: tar Zcvf FileName.tar. Z DirName
---------------
. Zip
Decompress: unzip FileName.zip
Compression: zip FileName.zip DirName
Use the-r parameter to compress a directory and use-r recursion. Example: $ zip-r FileName.zip DirName
---------------
. Rar
Decompress: rar x FileName.rar
Compression: rar a FileName.rar DirName

Rar Please download to: http://www.rarsoft.com/download.htm!
After decompression, copy rar_static to the/usr/bin directory (Other Directories specified by the $ PATH environment variable can also be used ):
[Root @ localhost usr] # cp rar_static/usr/bin/rar
---------------
. Lha
Decompress: lha-e FileName. lha
Compression: lha-a FileName. lha FileName

Lha please: http://www.infor.kanazawa-it.ac.jp /~ Ishii/lhaunix/download!
> After decompression, copy lha to the/usr/bin directory (Other Directories specified by the $ PATH environment variable can also be used ):
[Root @ localhost usr] # cp lha/usr/bin/
---------------
. Rpm
Unpack: rpm2cpio FileName. rpm | cpio-div
---------------
. Deb
Unpack: ar p FileName. deb data.tar.gz | tar zxf-
---------------
. Tar. tgz .tar.gz. tar. Z. tar. bz .tar.bz2. zip
. Cpio. rpm. deb. slp. arj. rar. ace. lha. lzh. lzx. lzs
. Arc. sda. sfx. lnx. zoo. cab. kar. cpt. pit. sit. sea
Decompress: sEx x FileName .*
Compression: sEx a FileName. * FileName

SEx only calls related programs and does not support compression or decompression. Please note!
For sEx, go to http://sourceforge.net/projects/sexto download it!
After decompression, copy sEx to the/usr/bin directory (Other Directories specified by the $ PATH environment variable can also be used ):
[Root @ localhost usr] # cp sEx/usr/bin/

Common file decompression methods and commands in Linux

1. Files with. a extension:
# Tar xv file.
2. files with the. z extension:
# Uncompress file. Z
3.files with the extension of .gz:
# Gunzip file.gz
4.files with the extension of .bz2:
# Bunzip2 file.bz2
5.files with the extension of .tar. Z:
# Tar xvZf file.tar. Z
Or # compress-dc file.tar. Z | tar xvf
6.files with the extension .tar.gz/. tgz:
# Tar xvzf file.tar.gz
Or gzip-dc file.tar.gz | tar xvf-
7.files with the extension of .tar.bz2:
# Tar xvIf file.tar.bz2
Or bzip2-dc file.tar.bz2 | xvf-
8.files with the extension .cpio.gz/. cgz:
# Gzip-dc file. cgz | cpio-div
9. files with the. cpio/cpio extension:
# Cpio-div file. cpio
Or cpio-divc file. cpio
10. Install files with the. rpm extension:
# Rpm-I file. rpm
11. decompress the file with the. rpm extension:
# Rpm2cpio file. rpm | cpio-div
12. Install files with the. deb extension:
# Dpkg-I file. deb
13. decompress the file with the. deb extension:
# Dpkg-deb-fsys-tarfile file. deb | tar xvf-ar p
File. deb data.tar.gz | tar xvzf-
14.files with the extension of .zip:
# Unzip file.zip
Decompress Winzip files in linux
If jdk is installed, you can use the jar command and the unzip command.
Directly decompress the .tar.gz File
The xxxx.tar.gz file uses tar with the zxvf parameter and can be decompressed once. XXXX is the file name. For example:
$ Tar zxvf xxxx.tar.gz decompress various compressed files (Installation Method)

Decompress the file extension (Installation Method)
. A ar xv file.
. Z uncompress file. Z
. Gz gunzip file.gz
. Bz2 bunzip2 file.bz2
. Tar. Z tar xvZf file.tar. Z
Compress-dc file.tar. Z | tar xvf-
.Tar.gz/. tgz tar xvzf file.tar.gz
Gzip-dc file.tar.gz | tar xvf-
.Tar.bz2 tar xvIf file.tar.bz2
Bzip2-dc file.tar.bz2 | xvf-
.Cpio.gz/. cgz gzip-dc file. cgz | cpio-div
. Cpio/cpio-div file. cpio
Cpio-divc file. cpio
. Rpm/install rpm-I file. rpm
. Rpm/extract rpm2cpio file. rpm | cpio-div
. Deb/install dpkg-I file. deb
. Deb/exrtact dpkg-deb-fsys-tarfile file. deb | tar xvf-
Ar p file. deb data.tar.gz | tar xvzf-
. Zip unzip file.zip

Bzip2-d myfile.tar.bz2 | tar xvf

Tar xvfz myfile.tar.bz2

X is decompression
V is a complex output.
F is the specified file
Z gz format

Gzip
Gzip [Option] file name to be compressed (or decompressed)
-C writes the output to the standard output and keeps the original file.
-D: compress the compressed file.
-L the following fields are displayed for each compressed file: size of the compressed file, size of the uncompressed file, compression ratio, and name of the uncompressed file.
-R recursively searches for the specified directory and compresses or compresses all the files in it.
-T to test whether the compressed file is complete.
-V shows the file name and compression ratio of each compressed and decompressed file.
-Num-adjust the compression speed with the specified number.
Example:
Create a full file named usr.tar in the full directory of the/usrdirectory.
Tar cvf usr.tar/home
Create and compress all the directories in the/usr directory. The file name is usr.tar.gz.
Tar czvf usr.tar.gz/usr
A group of files with the suffix tar.gz
# Tar cvf back.tar/back/
# Gzip-q back.tar
Or
# Tar cvfz back.tar.gz/back/
Release a file suffixed with tar.gz.
# Tar zxvf back.tar.gz
# Gzip back.tar.gz
# Tar xvf back.tar

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.