Linux, such as compressed tar bz gz compression and decompression

2011-02-12  来源:本站原创  分类:OS  人气:130 

Extract on quite familiar with, and suddenly do not know how to compress . . . Ashamed. .

This is available online approach:

. Tar . GZ
Extract : Tar zxvf FileName. Tar . GZ
Compression : Tar zcvf FileName. Tar . GZ DirName

Roughly summed up what the Linux of various formats compressed packet compression , decompression method. But I did not use some method, also incomplete, I hope you help me add that I will be ready to revise and improve, thank you!
. Tar
Unpack: Tar xvf FileName. Tar
Packaging: Tar CVF FileName. Tar DirName
(Note: Tar is packaged, not compressed !)
---------------------------------------------
. Gz
Extract 1: gunzip FileName.gz
Extract 2: gzip-d FileName.gz
Compression : gzip FileName
. Tar . GZ and. tgz
Extract : Tar zxvf FileName. Tar . GZ
Compression : Tar zcvf FileName. Tar . GZ DirName
---------------------------------------------
. Bz2
Extract 1: bzip2-d FileName.bz2
Extract 2: bunzip2 FileName.bz2
Compression : bzip2-z FileName
. Tar . bz2
Extract : Tar jxvf FileName. Tar . bz2
Compression : Tar jcvf FileName. Tar . bz2 DirName
---------------------------------------------
. Bz
Extract 1: bzip2-d FileName.bz
Extract 2: bunzip2 FileName.bz
Compression : Unknown. Tar . BZ
Extract : Tar jxvf FileName. Tar . BZ
Compression : Unknown ---------------------------------------------
. Z
Extract : uncompress FileName.Z
Compression : compress FileName
. Tar . Z
Extract : Tar zxvf FileName. Tar . Z
Compression : Tar Zcvf FileName. Tar . Z DirName
---------------------------------------------
. Zip
Extract : unzip FileName.zip
Compression : zip FileName.zip DirName
---------------------------------------------
. Rar
Extract : rar x FileName.rar
Compression : rar a FileName.rar DirName

rar go to: http://www.rarsoft.com/download.htm Download!
Decompression after please rar_static copy / usr / bin directory (the other by the $ PATH environment variable specifies the directory can be):
[Root @ www2 tmp] # cp rar_static / usr / bin / rar
---------------------------------------------
. Lha
Extract : lha-e FileName.lha
Compression : lha-a FileName.lha FileName

lha go to: http://www.infor.kanazawa-it.ac.jp/ ~ Ishii / lhaunix / Download!
> extract which you may copy lha / usr / bin directory (the other by the $ PATH environment variable specifies the directory can be):
[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 -
---------------------------------------------
. 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
Extract : sEx x FileName .*
Compression : sEx a FileName .* FileName

sEx simply calls the associated program itself has no compression , decompression function, please note!
sEx go to: http://sourceforge.net/projects/sex Download!
Decompression after please sEx copy / usr / bin directory (the other by the $ PATH environment variable specifies the directory can be):
[Root @ www2 tmp] # cp sEx / usr / bin /

References: Linux file compression tool guide (in fact, help is the best way to see the general commands can be used in all "- help" argument has been common to use!)

Users often need to back up the data in a computer system, in order to save storage space, often the backup file compression . The following describes the backup and compression of the command.

Tar command

Tar files can create files and directories. The use of Tar , the user can create files for a particular file (backup file), you can also change the file in the file or files to add new files. Tar was originally used to create files on tape, now, users can create files on any device, such as a floppy disk. The use of Tar command, you can put a lot of files and directories all packaged into a file, which for the backup file or several files together into one file so that network traffic is very useful. Linux on the Tar is the GNU version.

Syntax: Tar [main options + secondary options] files or directories

Use this command, the main option is to have, it tells Tar what to do, is to assist the use of secondary options, you can use.

Main options:

c create new archive files. If you want to backup a directory or some files, they should choose this option.

r the archived files to append to file end of the file. For example, the user is well backed up files, and found that there is a directory or forgot some files backed up, then you can use this option, will forget the directory or file is appended to the backup file.

t list the contents of the archive to see what files have been backed up.

u Update files. That is, with the new document replaces the original backup file, if you can not find the file in the backup file to be updated, then it is appended to the end of the backup file.

x release from the archive file.

Accessibility:

b This option is set for the tape drive. Followed by a number, used to describe the block size, the system default is 20 (20 * 512 bytes).

f Use the archive file or device, this option is usually not optional.

k to save the file already exists. For example, we have to restore a file, the restore process, encountering the same file, will not be covered.

m in the restore files, file modification time all set now.

M to create multi-volume archive, stored for several disk.

v detailed report Tar file information processing. The absence of such options, Tar file information is not reported.

w asked to confirm each step.

z gzip to compress / de- compressed files, plus the option file after file compression , but it is also necessary to restore this option to extract the compressed .

Example 1: the / home directory including its subdirectories to do all the backup files, backup files named usr. Tar .

$ Tar CVF usr. Tar / Home

Example 2: the / home directory, including all its subdirectories to back up files, and compressed , backup file called usr. Tar . GZ.

$ Tar czvf usr. Tar . GZ / Home

Example 3: usr. Tar . GZ restore the backup file and extract the compressed .

$ Tar xzvf usr. Tar . GZ

Example 4: Check usr. Tar content of the backup file, and split-screen display on the monitor.

$ Tar tvf usr. Tar | more

To back up files to a specific device, just the device name as the backup file name.

Example 5: user / dev/fd0 the floppy disk device to create a backup file and the / home directory, all files are copied to the backup file.

$ Tar cf / dev/fd0 / Home

To restore the device disk file, use the xf options:

$ Tar XF / dev/fd0

If the backup file size exceeds the available storage space for equipment, such as a floppy disk, you can create a multi-volume Tar backup file. M option instructs the Tar command prompt you use a new storage device, when using the M option to archive to a floppy drive, when, Tar command on a floppy disk is full, when will alert you and then put a new floppy disk. So you can Tar the file into several disks.

$ Tar CMF / dev/fd0 / Home

To restore a few disk files, as long as the first into the drive, then enter the option with x and M Tar command. You will be necessary to remind a floppy disk into the other.

$ Tar XMF / dev/fd0

gzip command

Reduce the file size has two distinct advantages, one can reduce the storage space, the second is to transfer files across the network, you can reduce the transmission time. gzip in Linux systems often use one of the file compression reconciliation compress command, convenient and easy to use.

Syntax: gzip [options] compression (solution compressed ) file name

The meaning of each option:

-C writes output to standard output, and keep the original file.

-D will compress the file decompression .

-L For each compressed file, displays the following fields:

Compressed file size

Not compress the file size

Compression ratio

Not compress the file name

-R recursively find the specified directory and compress all the files in which the solution or compressed .

-T test, check the compressed file is complete.

-V for each compression and decompression of files, file name and compression ratio.

-Num num adjusted with the specified number of 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). System default is 6.

Suppose a / home file under mm.txt, sort.txt, xx.com.

Example 1: the / home directory for each file compressed into a. gz files.

$ Cd / home

$ Gzip *

$ Ls

m.txt.gz sort.txt.gz xx.com.gz

Example 2: Example 1 of each compressed file decompression , and lists detailed information.

$ Gzip-dv *

mm.txt.gz 43.1 %----- replaced with mm.txt

sort.txt.gz 43.1 %----- replaced with sort.txt

xx.com.gz 43.1 %----- replaced with xx.com

$ Ls

mm.txt sort.txt xx.com

Example 3: Example 1 showing details of each compressed file information is not extracted .

$ Gzip-l *

compressed uncompr. ratio uncompressed_name

277 445 43.1% mm.txt

278 445 43.1% sort.txt

277 445 43.1% xx.com

$ Ls

mm.txt.gz sort.txt.gz xx.com.gz

Example 4: compress a Tar backup file, such as usr. Tar , then compress the file extension. Tar . GZ

$ Gzip usr. Tar

$ Ls

usr. Tar . GZ

unzip command

Under MS Windows using the compression software winzip compressed files how Linux system launched? You can use the unzip command, which is used to understand the extension. Zip the compressed file.

Syntax: unzip [options] compressed file name. zip

The meaning of each option are as follows:

-X file list solution of compressed files, but does not include the specified file file.

-V view the compressed file directory, but does not extract .

-T Test file for damage, but does not extract .

-D directory to compress the files into the specified directory.

-Z display only compressed file comments.

-N Do not overwrite existing files.

-O overwrite existing files without asking for user confirmation.

-J does not rebuild the directory structure of the document, all the files extract to the same directory.

Example 1: The compressed file text.zip solution in the current directory compression .

$ Unzip text.zip

Example 2: The compressed file text.zip in the specified directory under / tmp solution of compression , if the same file already exists, requires the unzip command does not overwrite the original file.

$ Unzip-n text.zip-d / tmp

Example 3: See compressed file directory, but does not extract .

$ Unzip-v text.zip

zgrep command

This command functions in the compressed file to find the matching regular expression, use the grep command the same, but the operation object is compressed files. If you want to see in a compressed file, there is no one word can be used zgrep command.

相关文章