File compression and Packaging---compress,gzip,zcat,bzip2,bzcat,tar,find,tarfile,tarball under Linux

Source: Internet
Author: User

Common Linux Compressed file extensions

*. Z Compress compressed files (has been replaced by gzip)

*.gz gzip Program Compressed files

*.BZ2 BZIP2 Program Compressed files (better than gzip, but only for one file to compress)

*.tar Tar program packaged data, no compression (using tar to package a file, you can solve the problem that bzip2 cannot compress multiple files)

*.tar.gz Tar program packaged data, and gzip compressed

*.TAR.BZ2 the TAR program to package the data and pass the BZIP2 compression


Compress using the Ubuntu installation command:

Apt-get Install Compress


Operation Command:

The target file is replaced after executing the command

Compress compress [-RCV] file name or directory name

Unzip the uncompress file name. z


Execute command does not replace target file

Compress compress-c target file name > new file name

Main parameters:

-R: Compressed files in connected directory

-C: Output compressed data to the screen (without actual compression)

-V: Output of compressed file information and file changes (not actually compressed)


Use of Gzip,zcat

Gzip can unlock compress,zip and gzip compressed files, zip file extension gz

Operation Command:

gzip [-cdtv#] file name or directory name

Zcat file name. GZ does not unzip the contents of the output compressed file on the screen


Execute command does not replace target file

Gzip-c target file name > new file name

gizp-d target file name > new file name

Main parameters:

-C: Output compressed data to the screen

-D: decompressed parameters

-T: Used to verify the consistency of a compressed file to see if there are errors

-V: Displays compression ratio information for the original file/compressed file

-#: Compression level, 1 fastest, 9 slowest, default-6, slow speed and compression ratio inversely proportional


Gunzip is also a decompression command


Bzip2,bzcat the use of the operation command:

bzip2 [-cdkzv#] File name

Bzcat file name. bz2

Main parameters:

-C: Output compression generated data to the screen

-D: decompression parameters

-K: retains the original file and does not delete the original file

-Z: Compressed parameters

-V: Displays compression ratio information for the original file/compressed file

-V: Same as Gzip


The BUNZIP2 command can also be used to decompress


Package Command: Tar operation command:

Package and compress: tar [-j|-z] [cv] [-f file name]

View files: tar [-j|-z] [tv] [-f filename]

Decompression: tar [-j|-z] [xv] [-f filename] [-C directory]


Main parameters:

-C: Create a packaged file that can be paired with-V to see the file name being packaged in the process

-T: See what files are included in the packaged file

-X: Decompression or unpacking function, can be solved with-C (uppercase) in a specific directory,-c,-t,-x can not appear in a series of commands

-J: Compression/Decompression with BZIP2 support: This file name is preferably *.tar.bz2

-Z: Compression/Decompression with GZIP support: This file name is preferably *.tar.gz

-V: Displays the file name being processed during the compression/decompression process

-F FileName: The file name to be processed immediately after-F

-C Directory: This option is used for decompression, which can be used in specific directory decompression


-P: (lowercase p) retains the original permissions and attributes of the backup data, typically used to back up important configuration files, important parameters

-P: (uppercase P) retains absolute path, allowing the backup data to contain the root directory exists

--exclude=file: During compression, do not package FILE


Tip: How to extract a single file within a package

Tar-jtv-f directory/file name. tar.bz2 | grep ' Find the string '


grep is the ability to search for keywords after locating the target directory


Tar-jxv-f package file name. tar.bz2 Unlock target directory


A way to package a directory without some files in that directory

Tar-jcv-f/root/etc.tar.bz2--exclude=/root/etc* >--exclude=/root/etc.tar.bz2/etc/root


Backup only new files than at some point

--newer Options and--newer-mtime

--newer indicates that the Mtime and CTime are later included.

The--newer-mtime is only mtime


Use FIND/ETC-NEWER/ETC/PASSWD to find out more new files

Time to find a target file

Tar-jcv-f/root/etc.tar.bz2 >--newer-mtime= "2011/10/3"/etc/*


Tarfile,tarballtarfile

Only use the TAR directive to package files that are not compressed

Tarball

Files packaged and compressed using the TAR directive


Methods of using the TAR command to be/dev/st0 to a tape drive

Tar-cv-f/dev/st0/home/root/etc


Using pipeline command and data flow backup

It's the side pack. Unzip to the target directory

Cd/tmp

TAR-CVF-/ETC|TAR-XVF-

That is: Copy the information under/etc directly to the directory where the path is/tmp

File compression and Packaging---compress,gzip,zcat,bzip2,bzcat,tar,find,tarfile,tarball under Linux

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.