Java EE Development of various types of resources download list, the history of the most complete IT resources, personal collection summary.
Linux users often need to back up the computer system data, in order to save storage space, often the backup file compression, this article is the compression and decompression command of the general summary
. tar.gz
Decompression: Tar zxvf FileName.tar.gz
Compression: Tar zcvf FileName.tar.gz dirname
The Solaris decompression *.tar.gz may be somewhat different, and the following two steps are required for decompression:
1, gzip-d *.tar.gz
2, Tar xvf *.tar
The first step is to extract the *.tar.gz format into the *.tar format
The second step, the direct decompression *.tar format file, complete decompression
---------------------------------------------
. tar
Unpack: Tar xvf Filename.tar
Tar xvf filename.tar-c dirname (extract to specified folder dirname)
Packing: Tar cvf filename.tar dirname
---------------------------------------------
. 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 FileName
---------------------------------------------
. 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 FileName
---------------------------------------------
. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:BUNZIP2 filename.bz
Compression: Unknown
. Tar.bz
Decompression: Tar jxvf FileName.tar.bz
Compression: Tar jcvf FileName.tar.bz FileName
---------------------------------------------
. 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 go 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 go 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/
Reference Documents: Linux File Compression Tools Guide
In fact, looking at help is the best way, the general commands can be used "--help" parameters or Man command (such as: Man tar) to get the commonly used methods.
---------------------------------------------
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, you can use this option when you have a backup file and then find a directory or file that needs to be backed up.
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 (compressed)
Size of uncompressed file (uncompressed)
Compression ratio (ratio)
Name of uncompressed file (Uncompressed_name)
-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 compression with the specified number num, -1 (--fast) represents the fastest compression method (low compression ratio), and -9 (--best) represents the slowest compression method (high compression ratio). The default value for the system is 6.
Suppose a directory/home under a file 123 AAA ABC
Example 1: Compress each file in the/home directory into a. gz file.
$ cd/home
$ gzip *
$ ls
123.gz aaa.gz abc.gz
Example 2: Unzip each compressed file in Example 1 and list detailed information.
$ GZIP-DV *
123.gz: -50.0%--Replaced with 123
Aaa.gz: -50.0%--Replaced with AAA
Abc.gz: -50.0%--Replaced with ABC
$ ls
123 AAA ABC
Example 3: Details the information of each compressed file in Example 1 and does not understand the pressure.
$ gzip-l * Compressed uncompressed ratio uncompressed_name
28 4-50.0% 123
4-50.0% AAA
4-50.0% ABC
12-416.7% (totals)
$ ls
123.gz aaa.gz abc.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 to use compressed software from MS Windows to WinZip compressed files under Linux system. You can use the Unzip command, which is used to extract a compressed file with a. 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.