This is the method provided online:
. tar.gz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz DirName1 DirName2
Roughly summed up the Linux under the various formats of compression package compression, decompression methods. But some methods I did not use, also not all, I hope you help me to add, I will be ready to modify, thank you!
. tar
Unpack: Tar xvf Filename.tar
Packing: Tar cvf filename.tar dirname
(Note: Tar is packed, not compressed!)
---------------------------------------------
. gz
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName
. tar.gz and. tgz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz dirname
---------------------------------------------
. bz2
Decompression 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: Bzip2-z FileName
. tar.bz2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar jcvf FileName.tar.bz2 dirname
---------------------------------------------
. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown
. tar.bz
Decompression: Tar jxvf FileName.tar.bz
Compression: Unknown
---------------------------------------------
. Z
Decompression: uncompress filename.z
Compression: Compress FileName
. Tar. Z
Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z dirname
---------------------------------------------
. zip
Decompression: Unzip Filename.zip
Compression: Zip Filename.zip dirname
---------------------------------------------
. rar
Decompression: rar x Filename.rar
Compression: rar a filename.rar dirname
RAR please to: http://www.rarsoft.com/download.htm download!
After decompression, copy the rar_static to the/usr/bin directory (other directories specified by the $PATH environment variable can also):
[ROOT@WWW2 tmp]# CP Rar_static/usr/bin/rar
---------------------------------------------
. Lha
Decompression: Lha-e Filename.lha
Compression: Lha-a Filename.lha FileName
LHA please to: http://www.infor.kanazawa-it.ac.jp/~ishii/lhaunix/download!
> Copy the LHA to the/usr/bin directory after decompression (other directories specified by the $PATH environment variable may also be available):
[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. Ace. Lha. LZH lzx. Lzs. SDA
. Zoo. cab. kar. cpt. Pit. Sit-Sea
Decompression: sEx x filename.*
Compression: SEx a filename.* FileName
Sex just call the relevant program, itself and no compression, decompression function, please note!
Sex please to: http://sourceforge.net/projects/sex download!
After decompression, copy the sex to the/usr/bin directory (other directories specified by the $PATH environment variable can also):
[ROOT@WWW2 tmp]# CP sex/usr/bin/
References: Linux file compression Tools Guide
(In fact, see Help is the best way, general commands can be used "--help" parameters to get commonly used methods!)
Users often need to back up the data in the computer system, in order to save storage space, the backup files are often compressed. The following are the commands for backup and compression, respectively.
Tar command
Tar can create archives for files and directories. With tar, users can create files for a particular file (backup files), change files in their files, or add new files to the file. Tar was originally used to create files on tape, and now users can create files on any device, such as a floppy disk. With the tar command, you can package a large number of files and directories into a single file, which is useful for backing up files or combining several files into a single file for easy network transmission. The tar on Linux is the GNU version.
Syntax: tar [main options + auxiliary options] File or directory
When using this command, the main option is required, it tells Tar what to do, the auxiliary option is auxiliary, and can be selected.
Main options:
C Create a new profile. If the user wants to back up a directory or some files, select this option.
R Append files to archive to the end of the file. For example, the user has made a backup file, and found that there is a directory or some files forgotten to back up, you can use this option to append the forgotten directories or files to the backup file.
T lists the contents of the profile to see which files have been backed up.
U update files. That is, replace the original backup file with the new file, and append it to the end of the backup file if the file you want to update cannot be found in the backup file.
X releases the file from the profile.
Accessibility Options:
b This option is set for the tape drive. followed by a number to indicate the size of the block, the system preset is 20*512 bytes.
F Use an archive file or device, this option is usually required.
K to save a file that already exists. For example, we restore a file, in the process of restoration, encountered the same file, will not be overwritten.
m when restoring the file, set all files to the current change time.
M to create a multiple-volume profile for storage on several disks.
V Detailed report of tar processing file information. Without this option, TAR does not report file information.
W each step is required to confirm.
Z use gzip to compress/decompress files, plus this option to compress the profile, but be sure to use this option to decompress when restoring.
Example 1: The/home directory includes its subdirectories to do all the backup files, the backup file name is Usr.tar.
$ tar cvf usr.tar/home
Example 2: The/home directory includes its subdirectories to do all the backup files, and compression, backup file name usr.tar.gz.
$ tar czvf usr.tar.gz/home
Example 3: Restore and decompress usr.tar.gz this backup file.
$ tar xzvf usr.tar.gz
Example 4: View the contents of the Usr.tar backup file and display it on the monitor in a split-screen manner.
$ tar TVF Usr.tar | More
To back up a file to a specific device, simply use the device name as the backup file name.
Example 5: The user creates a backup file on the floppy disk of the/DEV/FD0 device and copies all the files in the/home directory to the backup file.
$ tar Cf/dev/fd0/home
To recover files on a device disk, use the XF option:
$ tar xf/dev/fd0
If a user backs up a file that exceeds the storage space available to the device, such as a floppy disk, you can create a multiple-volume tar backup file. The M option instructs the tar command to prompt you to use a new storage device, and when the M option is used to archive a floppy drive, the TAR command reminds you to put a new floppy disk when a floppy disk is full. This allows you to save the tar file on several disks.
$ tar Cmf/dev/fd0/home
To recover files from several disks, simply put the first one in the floppy drive and enter the TAR command with the X and M options. If necessary, you will be reminded to put in a different floppy disk.
$ tar xmf/dev/fd0
gzip command
Reducing file size has two obvious benefits, one is to reduce storage space, and the other is to transfer files over the network, you can reduce the transmission time. Gzip is a regular use of Linux in the file compression and decompression of the command, both convenient and useful.
Syntax: gzip [option] Compressed (uncompressed) file name
Meaning of each option:
-C writes the output to the standard output and retains the original file.
-D Unzip the compressed file.
-L Displays the following fields for each compressed file:
Size of compressed file
Size of uncompressed file
Compression ratio
Name of uncompressed file
-R recursively finds the specified directory and compresses all files in it or is uncompressed.
-T test to check that the compressed file is complete.
-V displays filename and compression ratio for each compressed and decompressed file.
-num adjusts the speed of the compression with the specified number num,-1 or--fast represents the fastest compression method (low compression ratio),-9 or--best represents the slowest compression method (high compression ratio). The default value for the system is 6.
Suppose a directory/home a file mm.txt, Sort.txt, xx.com.
Example 1: Compress each file in the/home directory into a. gz file.
$ cd/home
$ gzip *
$ ls
m.txt.gz sort.txt.gz xx.com.gz
Example 2: Unzip each compressed file in Example 1 and list 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: Details the information of each compressed file in Example 1 and does not understand the pressure.
$ 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, at which time the compressed file extension is. tar.gz
$ gzip Usr.tar
$ ls
Usr.tar.gz
Unzip command
How do you winzip compressed files under MS Windows in a Linux system? You can use the Unzip command, which is used to extract compressed files with the. zip extension.
Syntax: Unzip [options] compress file names. zip
The meanings of each option are:
-X file list to extract the file, but not the specified file file.
-V View compressed file directory, but don't understand the pressure.
-t test file for damage, but no pressure.
The-D directory unzip the compressed file to the specified directory.
-Z Displays only the annotations of the compressed file.
-N does not overwrite files that already exist.
-O overwrites files that already exist and does not require user confirmation.
-j does not reconstruct the document's directory structure, extracting all files into the same directory.
Example 1: Unzip the compressed file Text.zip under the current directory.
$ unzip Text.zip
Example 2: Text.zip the compressed file in the specified directory/TMP, and if the same file exists, requires that the unzip command not overwrite the original file.
$ unzip-n text.zip-d/tmp
Example 3: View the compressed file directory, but do not understand the pressure.
$ unzip-v Text.zip
Zgrep command
The function of this command is to look for a matching regular expression in a compressed file, just like the grep command, except that the object of the operation is a compressed file. If a user wants to see if there is a word in a compressed file, the Zgrep command is available.