How to decompress and package commands in Linux

Source: Internet
Author: User
Tags 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
Install the appropriate software: sudo apt-Get install unrar RAR
Note that RAR is also a 30-day software trial in Linux, but you can choose to continue using it
Decompress: RAR x filename.rar
Compression: rar a filename.rar dirname
RAR also go to: http://www.rarsoft.com/download.htm download!
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-
---------------
. 7z
Install the appropriate software: sudo apt-Get install p7zip-full
List Files: 7z l file.7z
Decompress: 7z x file.7z
---------------
. 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/

**************************************** ***************************************
Appendix

Decompress various compressed files and common decompression commands:
. 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.

Zip
# Unzip file.zip
Decompress WinZip files in Linux
If JDK is installed, you can use the jar command. Generally, you can use the unzip command, thanks to the cross-platform ZIP file format.

Examples of advanced compression commands:
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.