Linux decompression. Tar. tgz. tar.gz. Tar. Files such as Z

Source: Internet
Author: User
Tags gz file rar zip extension

. tar
Unpacking: Tar xvf Filename.tar
Package: Tar cvf filename.tar DirName
(Note: Tar is packaged, 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 go to:
Http://www.rarsoft.com/download.htm
Download!
After extracting, copy the rar_static to the/usr/bin directory (other directories specified by the $PATH environment variable can also):
[email protected] 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!
> After extracting, copy the LHA to the/usr/bin directory (other directories specified by the $PATH environment variable can also):
[email protected] tmp]# CP lha/usr/bin/
---------------------------------------------
. rpm
Unpacking: Rpm2cpio filename.rpm | Cpio-div
---------------------------------------------
. deb
Unpacking: 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
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 unpacking, copy the sex to the/usr/bin directory (other directories specified by the $PATH environment variable can also):
[email protected] tmp]# CP sex/usr/bin/
Reference documents:
Linux File Compression Tool guide
(In fact, see Help is the best way, the General command can use the "--help" parameter to get common use Method!) )
Users often need to back up the data in the computer system, and in order to save storage space, the backup files are often compressed. The following describes the commands for backup and compression, respectively.
Tar command
Tar can create archives for files and directories. With tar, users can create files (backup files) for a particular file, or they can change files in the file or add new files to the archive.
Tar was originally used to create files on tapes, and currently, users can create files on all devices, such as floppy disks. With the tar command, you can package a whole bunch of files and directories into a single file, which
It is useful to back up files or to combine several files into one file for easy network transmission. The tar on Linux is the GNU version.
Syntax: tar [main option + Secondary options] file or directory
When using this command, the main option is necessary, and he tells Tar what to do, auxiliary options are auxiliary and can be used.
Main options:
C Create a new profile. Select this option if the user wants to back up a directory or some files.
R appends the file to be archived to the end of the archive file. For example, the user has made a backup file, and found that more than one directory or some files forgot to back up, this option can be used to append the forgotten directories or files to the backup file.
T list the contents of the archive file and see which files have been backed up.
U update file. That is, replace the original backup file with the new file, if the file you want to update is not found in the backup file, append it to the end of the backup file.
X release the file from the archive file.
Accessibility Options:
b This option is set for the tape drive. It is followed by a number that indicates the size of the chunk and the system preset value is (20*512 bytes).
F using a file or device, this option is usually required.
K Save the file that already exists. For example, we restore a file, during the restore process, encountered the same file, will not be overwritten.
m when restoring files, set the modification time of all files to current.
M Create a multi-volume archive file for storage on several disks.
V Detailed report of file information processed by tar. Without this option, TAR does not report file information.
W each step requires confirmation.
Use gzip to compress/unzip the file, plus this option to compress the archive file, but be sure to unzip it using this option when restoring.
Example 1: The Home/home directory including his subdirectories are all backup files, the backup file name is Usr.tar.
$ tar cvf usr.tar/home
Example 2: The home/home directory including his subdirectories are all backup files, and compression, backup file name is usr.tar.gz.
$ tar czvf usr.tar.gz/home
Example 3: Restore and decompress the usr.tar.gz backup file.
$ tar xzvf usr.tar.gz
Example 4: View the contents of the Usr.tar backup file and display it on the display in Split-screen mode.
$ 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 restore files from your device's disk, use the XF option:
$ tar xf/dev/fd0
If a user backs up a file that is larger than the storage space available to the device, such as a floppy disk, you can create a multi-volume tar backup file. The M option instructs the tar command to prompt you to use a new storage device when
When using the M option to archive a floppy drive, the TAR command reminds you to put a new floppy disk when a floppy disk is full. So you can put the tar file on a few 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. You will be reminded to put another floppy disk if necessary.
$ tar xmf/dev/fd0
gzip command
There are two obvious benefits of reducing file size, one is to reduce storage space, and the other is to reduce transmission time when transferring files over the network. Gzip is a frequently used Linux system command to compress and decompress files, which is both convenient and useful.
Syntax: gzip [option] File name for compression (decompression)
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 files
Size of uncompressed files
Compression ratio
The name of the uncompressed file
-R recursively finds the specified directory and compresses all of its files or unzip it.
-T test to check that the compressed file is complete.
-V for each compression and decompression file, display the filename and compression ratio.
-num adjusts the speed of 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 system default value is 6.
Suppose a directory/home has files 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: Detailed information about each compressed file in Example 1, and do 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, when the zip file has the extension. tar.gz
$ gzip Usr.tar
$ ls
Usr.tar.gz
Unzip command
Using the MS Windows system compression software WinZip compressed files how to expand under the 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 name. zip
The meanings of each option are:
-X file list to unzip the file, but not include the specified file file.
-V View the compressed Files directory, but do not press.
The-t test file has no damage, but does not understand the pressure.
The-D directory unlocks the compressed file to the specified directory.
-Z displays only annotations for compressed files.
-N does not overwrite files that already exist.
-O overwrites files that already exist and does not require user confirmation.
-j does not rebuild the directory structure of the file, extracting all the files into the same directory.
Example 1: Unzip the compressed file Text.zip in the current directory.
$ unzip Text.zip
Example 2: Extract the compressed file Text.zip in the specified directory/TMP, if the same file exists, the requirement Unzip command does not overwrite the original file.
$ unzip-n text.zip-d/tmp
Example 3: View the compressed Files directory, but do not understand the pressure.
$ unzip-v Text.zip
Zgrep command
The function of this command is to find a matching regular expression in a compressed file, using the same as the grep command, except that the object is to compress the file. If the user wants to see if there is a certain sentence in a compressed file, the Zgrep command is available: tar
Unpacking: Tar xvf Filename.tar
Package: Tar cvf filename.tar DirName
(Note: Tar is packaged, not compressed!) )

Linux decompression. Tar. tgz. tar.gz. Tar. Files such as Z

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.