Linux tar unzip GZ decompress bz2 and other methods to decompress files

Source: Internet
Author: User
Tags gz file tar unzip unpack uncompress

. Tar
Unpack: Tar xvf filename.tar
Package: Tar CVF filename.tar dirname
(Note: tar is packed, not 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 @ www2 TMP] # 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 @ www2 TMP] # 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 @ www2 TMP] # cp sex/usr/bin/

Common file decompression methods and commands in Linux
System-System
  
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

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.