Zip compressed uncompressed folder under Linux __linux

Source: Internet
Author: User
Tags bz2 pack rar



Instance: compressing the contents of the current directory on the server as xxx.zip files


Zip-r xxx.zip./*


Unzip the zip file to the current directory


Unzip Filename.zip


============================


Another: Some servers do not have the zip package to execute the zip command, but basically can use the tar command, the example is as follows:





tar-zcvf/home/zdzlibs.tar.gz/home/zdz/java/zdzlibs/
============================


Linux zip command


Zip-r myfile.zip./*
Compresses all files and folders in the current directory into Myfile.zip files, and-R represents all files under a recursive compression subdirectory.


2.unzip
Unzip-o-d/home/sunny Myfile.zip
Extract the Myfile.zip file to the/home/sunny/
-O: Overwrite files without prompting;
-d:-d/home/sunny to extract the file into the/home/sunny directory;


3. Other
zip-d Myfile.zip Smart.txt
Delete smart.txt files in compressed files
Zip-m Myfile.zip./rpm_info.txt
Add Rpm_info.txt file to Myfile.zip in compressed file
-------------------------------------------------------------------------------


To compress the file using Zip, type the following command at the shell prompt:


Zip-r Filename.zip Filesdir



In this example, Filename.zip represents the file you created, and Filesdir represents the directory where you want to place the new zip file. The-r option specifies that you want to include all files included in the Filesdir directory recursively (recursively).


To extract the contents of a zip file, type the following command:


Unzip Filename.zip



You can use the zip command to work with multiple files and directories at the same time by listing them individually and spacing by space:


Zip-r filename.zip file1 file2 file3/usr/work/school



The above command compresses the contents of the File1, File2, File3, and/usr/work/school directories (assuming this directory exists) and puts them into the Filename.zip file.





Tar command detailed


-C: Set up compressed files


-X: Decompression


-T: viewing content


-R: Appending files to the end of a compressed archive


-U: Updating files in original compressed package


These five are independent commands, compression decompression to use one of them, can be used with other commands but only one. The following parameters are optional when compressing or decompressing files as needed.


-C: Set up compressed files


-X: Decompression


-T: viewing content


-R: Appending files to the end of a compressed archive


-U: Updating files in original compressed package


The following parameter-F is required


-F: Use the file name, remember, this parameter is the last parameter, only the file name can be followed.


# TAR-CF All.tar *.jpg


This command is to make all. jpg files into a package named All.tar. -C indicates the creation of a new package,-f Specifies the file name of the package.


# TAR-RF All.tar *.gif


This command adds all the. gif files to the All.tar package. -R means to add a file.


# Tar-uf All.tar logo.gif


This command updates the logo.gif file in the original tar package All.tar, and-U is the meaning of the update file.


# TAR-TF All.tar


This command lists all the files in the All.tar package----------T is the list of files


# TAR-XF All.tar


This command is to solve all the files in the All.tar package----------T is untied


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, and use gzip compression to generate a gzip compressed package named jpg.tar.gz


TAR–CJF jpg.tar.bz2 *.jpg//packages all JPG files in the directory into Jpg.tar, and uses bzip2 compression to generate a BZIP2 compressed package named jpg.tar.bz2


TAR–CZF jpg.tar.z *.jpg//packages all JPG files in the directory into Jpg.tar, and uses compress compression to generate a umcompress compressed package named 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 first download zip for Linux


Extract


TAR–XVF File.tar//Extract tar Pack


TAR-XZVF file.tar.gz//Decompression tar.gz


TAR-XJVF file.tar.bz2//Decompression tar.bz2


TAR–XZVF File.tar.z//extract tar. Z


Unrar e file.rar//decompression rar


Unzip File.zip/Unzip zip


Summarize


1, *.tar with TAR–XVF decompression


2, *.gz with gzip-d or gunzip decompression


3, *.tar.gz and *.tgz with TAR–XZF decompression


4, *.bz2 with bzip2-d or with BUNZIP2 decompression


5, *.tar.bz2 with TAR–XJF decompression


6, *. Z with uncompress decompression


7, *.tar. Z with TAR–XZF decompression


8, *.rar with Unrar e decompression


9, *.zip with unzip decompression
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.