Linux decompression in the current folder command Summary

Source: Internet
Author: User
Tags unpack uncompress

In liunx, extracting the current file is very simple. You can use the simplest tar command and unzip to implement it, but I will give you a variety of file extraction passwords in linux.

Instance

Tar-zcvf/home/ecshopa/public_html/uggbootf20101214.tar.gz *: compress all files in the current directory
Tar-zxvf/home/uggbootf/public_html/uggbootf20101214.tar.gz

Command

Unzip-o-d/var/lib/mysql mysql43.194-20101230.zip


Tar command details

-C: Create a compressed file

-X: Extract

-T: View content

-R: append an object to the end of the compressed archive object

-U: update files in the original compressed package

These five are independent commands, one of which must be used for compression and decompression. They can be used with other commands, but only one of them can be used. The following parameters are optional when files are compressed or decompressed as needed.

-C: Create a compressed file

-X: Extract

-T: View content

-R: append an object to the end of the compressed archive object

-U: update files in the original compressed package

The following parameter-f is required

-F: use the file name. Remember, this parameter is the last parameter and can only be followed by the file name.

# Tar-cf all.tar *. jpg

This command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-f specifies the package file name.

# Tar-rf all.tar *. gif

This command adds all .gif files to the package of all.tar. -R indicates adding files.

# Tar-uf all.tar logo.gif

This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.

# Tar-tf all.tar

This command is used to list all files in the all.tar package.-t is used to list objects.

# Tar-xf all.tar

This command is used to extract all the files in the all.tar package.

 
Compression

Tar-cvf jpg.tar *. jpg // pack all jpg files in the Directory into tar.jpg

Tar-czf jpg.tar.gz *. jpg // jpg

Tar-cjf jpg.tar.bz2 *. jpg // jpg

Tar-cZf jpg.tar. Z *. jpg // jpg. Z

Rar a jpg.rar *. jpg // rar format compression, You need to download rar for linux

Zip jpg.zip *. jpg // zip format compression, You need to download zip for linux first

Extract

Tar-xvf file.tar // decompress the tar package

Tar-xzvf file.tar.gz // decompress tar.gz

Tar-xjvf file.tar.bz2 // unzip tar.bz2

Tar-xZvf file.tar. Z // extract tar. Z

Unrar e file.rar // extract rar

Unzip file.zip // decompress the zip file

Summary

1. Decompress *. tar with tar-xvf

2. Use gzip-d or gunzip to decompress *. gz

3. Use tar-xzf to decompress * .tar.gz and *. tgz.

4. Use bzip2-d for *. bz2 or use bunzip2 for decompression.

5. Use tar-xjf to decompress * .tar.bz2

6. Use uncompress to decompress *. Z

7. Decompress *. tar. Z with tar-xZf

8. Extract files using unrar e for *. rar

9. Decompress *. zip with unzip

 

01-.tar format
Unpack: [********] $ tar xvf FileName.tar
Package: [*******] $ tar cvf FileName.tar DirName (Note: tar is packed, not compressed !)

02-.gz format
Extract 1: [********] $ gunzip FileName.gz
Decompress 2: [********] $ gzip-d FileName.gz
Compression: [********] $ gzip FileName

03-.tar.gz format
Decompress: [********] $ tar zxvf FileName.tar.gz
Compression: [********] $ tar zcvf FileName.tar.gz DirName

04-.bz2 format
Extract 1: [********] $ bzip2-d FileName.bz2
Decompress 2: [********] $ bunzip2 FileName.bz2
Compression: [********] $ bzip2-z FileName

05-.tar.bz2 format
Decompress: [********] $ tar jxvf FileName.tar.bz2
Compression: [********] $ tar jcvf FileName.tar.bz2 DirName

06-. bz format
Extract 1: [********] $ bzip2-d FileName. bz
Decompress 2: [********] $ bunzip2 FileName. bz

07-.tar. bz format
Decompress: [********] $ tar jxvf FileName.tar. bz

08-.Z format
Decompress: [********] $ uncompress FileName. Z
Compression: [********] $ compress FileName

09-.tar. Z format
Decompress: [********] $ tar Zxvf FileName.tar. Z
Compression: [********] $ tar Zcvf FileName.tar. Z DirName

10-. tgz format
Decompress: [********] $ tar zxvf FileName. tgz

11-.tar. tgz format
Decompress: [********] $ tar zxvf FileName.tar. tgz
Compression: [********] $ tar zcvf FileName.tar. tgz FileName

12-.zip format
Decompress: [********] $ unzip FileName.zip
Compression: [********] $ zip FileName.zip DirName

13-. lha format
Decompress: [********] $ lha-e FileName. lha
Compression: [********] $ lha-a FileName. lha FileName

14-.rar format
Decompress: [********] $ rar a FileName.rar
Compression: [********] $ rar e FileName.rar


How to decompress commands in linux


. 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
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
---------------
. Rar
Decompress: rar x FileName.rar
Compression: rar a FileName.rar DirName
---------------
. Lha
Decompress: lha-e FileName. lha
Compression: lha-a FileName. lha FileName
---------------
. 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!

Gzip command
There are two obvious advantages to reduce the file size. One is to reduce the storage space, and the other is to reduce the transmission time when the file is transmitted over the network. Gzip is a frequently used command in Linux to compress and decompress files, which is convenient and easy to use.

Syntax: gzip [Option] compressed (decompressed) file name the meaning of each option of this command is as follows:

-C writes the output to the standard output and keeps the original file. -D. decompress the compressed file. -L the following fields are displayed for each compressed file: size of the compressed file, size of the uncompressed file, and compression ratio; name of the uncompressed file-r recursively searches for the specified directory and compresses all the files or decompress them. -T test to check whether the compressed file is complete. -V displays the file name and compression ratio for each compressed and decompressed file. -Num uses the specified numeric num to adjust the compression speed.-1 or -- fast indicates the fastest compression method (low compression ratio), and-9 or -- best indicates the slowest compression method (high compression ratio ). The default value is 6. Command instance:

Gzip * % compresses each file in the current directory into A. gz file. Gzip-dv * % decompress each compressed file in the current directory and list detailed information. Gzip-l * % detailed information of each compressed file in Example 1 is displayed without decompression. Gzip usr.tar %: the compressed tar backup file usr.tar. the extension name of the compressed file is .tar.gz.

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.