For details about various compression and decompression methods in Linux/centos/redhat, centosredhat

Source: Internet
Author: User

For details about various compression and decompression methods in Linux/centos/redhat, centosredhat

1.Zip command

Zip-r myfile.zip ./*

Compress all files and folders in the current directory into myfile.zip files.-r indicates recursively compressing all files in the subdirectory.

2.Unzip

Unzip-o-d/root/myfile.zip

Decompress the myfile.zip file to/root/

-O: overwrite the file without prompting;

-D:-d/root indicates to extract the file to the/root directory;

3.Others

Zip-d myfile.zip test.txt

Delete the test.txt file from the compressed file

Zip-m myfile.zip./add.txt

Upload add.txt file in myfile.zipto the compressed file

4.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 used to compress or decompress files as needed.

Optional.

-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 // pack all jpg files in the Directory into jpg. tar, compress the files with gzip, and generate a compressed gzip package named

 

Jpg.tar.gz

Tar-cjf jpg.tar.bz2 *. jpg // pack all the jpg files in the Directory into jpg. tar, compress it with bzip2, and generate a bzip2 compressed package named

 

Jpg.tar.bz2

Tar-cZf jpg.tar. Z *. jpg // pack all the jpg files in the Directory into jpg. tar, compress the files with compress, and generate a compressed umcompress package,

 

The name is jpg.tar. 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

5.SummaryThis article is collected by www.169it.com

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

Source: Linux/centos/redhat

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.