How to decompress tar GZ bz2 tgz Z and many other compressed files in Linux
Zxvf
For those who are new to Linux, they will surely get dizzy with a bunch of various file names in Linux. . There are too few developers. This article will summarize these common compressed files. I hope you will not be confused when you encounter these files.
Before summarizing various types of compressed files, we should first clarify two concepts: Packaging and compression. Packaging refers to converting a large number of files or directories into a total file. Compression refers to converting a large file into a small file through some compression algorithms. Why do we need to differentiate these two concepts? In fact, this is because many Linux compression programs can only compress one file, so when you want to compress a large number of files, you have to use another tool to compress these files into a package and then compress the original compression program.
At the end of lifecycle. After the tar package is generated, you can use other programs to compress it. So let's first talk about the basic usage of the tar command:
There are many options for the tar command (which can be viewed using man TAR), but there are several commonly used options. The following is an example:
# Tar-CF all.tar *. jpg
This command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-F specifies the package file name.
# Tar-RF all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
# Tar-UF all.tar logo.gif
This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.
# Tar-TF all.tar
This command lists all the files in the all.tar package.-T indicates listing the files.
# Tar-XF all.tar
This command is used to extract all files in the all.tar package.-X is used to unlock the file.
The above is the most basic usage of tar. To help you compress or decompress files while packing and unpackage, tar provides a special feature. This means that tar can call other compression programs, such as gzip and Bzip2, while packaging or unpacking.
1) tar calls Gzip
Gzipis a program developed by gnuorganization. The file ending with .gz is the result of gzip compression. The decompress program relative to gzip is gunzip. Use the-Z parameter in tar to call gzip. The following is an example:
# Tar-CZF all.tar.gz *. jpg
Invalid.
# Tar-xzf all.tar.gz
This command unlocks the generated package.
2) tar call Bzip2
Bzip2is a more powerful compression program. The file ending with .bz2 is the result of Bzip2 compression. The decompress program relative to Bzip2 is bunzip2. Use the-J parameter in tar to callBzip2. The following is an example:
# Tar-CJF all.tar.bz2 *. jpg
Invalid.
# Tar-xjf all.tar.bz2
This command unlocks the generated package.
3) tar call compress:
Compress is also a compression program, but it seems that there are not as many people using compress as gzip and Bzip2 .. The file ending with Z is the result of Bzip2 compression. The decompress program relative to compress is uncompress. Use the-Z parameter in tar to call compress. The following is an example:
# Tar-CZF all.tar. z *. jpg
This command is to compress all .jpg files into a tar package and generate
An uncompress compressed package named all.tar. Z
# Tar-xzf all.tar. Z
This command is used to unbind the generated package.
**************************************** **************************************** ******************
With the above knowledge, you should be able to uncompress a variety of files, the following for the tar series of compressed files
As a summary:
1st pair of files ending with .tar
Tar-XF all.tar
2XX for the file ending with .gz
Gzip-D all.gz
Gunzip all.gz
32.16.tgzor .tar.gz
Tar-xzf all.tar.gz
Tar-xzf all. tgz
4)for the file ending with .bz2
Bzip2-D all.bz2
Bunzip2 all.bz2
5 bytes for the file ending with tar.bz2
Tar-xjf all.tar.bz2
6) for files ending with. Z
Uncompress all. Z
72.16.tar. Z
Tar-xzf all.tar. Z
In addition, Linux also has corresponding methods to decompress the compressed file .zipand .rar under windows.
Guys:
1)for. Zip
Linux provides zip and unzip programs, Zip is a compression program, and unzip is a decompression program. Their Parameters
There are many options. Here we will only give a brief introduction. We will still give an example to illustrate its usage:
# Zip all.zip *. jpg
This command compresses all .jpg files into a zip package.
# Unzip all.zip
This command decompress all files in all.zip.
2XX vs. .rar
Install sudo apt-Get install RAR unrar p7zip
// Create a soft link sudo ln-fs/usr/bin/RAR/usr/bin/unrar
// In this way, you only need to enter unrar in the command line to decompress Or compress the file. After the installation is complete, the archive Manager also integrates the RAR component.
To process the. rar file in linux, you need to install RAR for Linux. You can download the file from the Internet, but remember that RAR for Linux is not free. You can download rarfor Linux 3.2.0 from http://www.rarsoft.com/download.htmand install it:
# Tar-xzpvf rarlinux-3.2.0.tar.gz
# Cd RAR
# Make
After installation, there will be two programs, RAR and unrar. rar is a compression program, and unrar is a decompression program. They have many Parameter options. Here we will only give a brief introduction and give examples to illustrate their usage:
# Rar a all *. jpg
This command is to compress all. jpg files into a rarpackage named all.rar. the program will automatically append the. rar extension name to the package name.
# Unrar x all.rar
This command is to extract all files from all.rar.
So far, we have already introduced tar, Gzip, gunzip, Bzip2, bunzip2, compress, uncompress, example, in Linux ,. these 10 types of compressed files, zw..tar.zw..zipw.rar, have been decompressed. In the future, you should not have to worry about downloading a software and not knowing how to unbind it in Linux. In addition, the above method is basically effective for Unix.
This article describes the compressed files tar, Gzip, gunzip, Bzip2, bunzip2, compress, uncompress, zip, zip, example,. Z,. tar.z).zip#.rar in Linux.
**************************************** **************************************** **************************************** *
Detailed usage of the Linux tar command, common compressed file types, and decompression
Syntax: Tar [primary option + secondary option] file or directory
When you use this command, the main option is required, and it tells tar what to do. The auxiliary option is used for assistance and can be used.
Main options:
C. Create a new archive file. Select this option if you want to back up a directory or some files.
R: append the file to the end of the file. For example, if you have prepared a backup file and find that there is still a directory or some files have forgotten to be backed up, you can use this option to append the directory or files you have forgotten to the backup file.
T list the file content and check which files have been backed up.
U updates the file. That is to say, replace the original backup file with the new file. If the file to be updated cannot be found in the backup file, append it to the end of the backup file.
X release a file from the file.
Auxiliary options:
B. This option is set for the tape drive. It is followed by a number to describe the block size. The default value is 20 (20*512 bytes ).
F. This option is usually required when you use an archive file or device.
K. Save the existing files. For example, if we restore a file, the same file will not be overwritten during restoration.
M sets the modification time of all files to the present when restoring files.
M creates a multi-volume archive file to store it on several disks.
V detailed report on the file information processed by tar. If this option is not available, tar does not report file information.
W each step requires confirmation.
F: this parameter is required. Otherwise, you cannot find your tar file.
In fact, it seems redundant when used. Since it is mandatory, it is simply fixed to the tar command itself.
However, this is not the case. If you don't use this parameter, he will tell you the error "file does not exist ".
People think this is a poorly designed software (or a command to put it)
V is also very important. Generally, we can see the details.
Therefore, the command is usually used to construct a tar package.
Tar CVF tarpackage name .tar directory, file list
The so-called directory file list is to split files and directories in the form of spaces
The tar package is usually a command.
Tar xvf tar .tar directory, file list
Tar files are collections of several files and/or directories in one file. This is an excellent path for creating backups and archives.
Tar uses the following options:
-C-create a new archive.
-F-when used together with the-C option, the created tar file uses the file name specified by this option. When used together with the-x option, the archive specified by this option is removed.
-T-displays the list of files included in the TAR file.
-V-displays the file archiving progress.
-X-Extract files from the archive.
-Z-use gzip to compress the tar file.
-J-use Bzip2 to compress the tar file.
To create a tar file, type:
Tar-CVF filename.tar directory/File
You can use the tar command to process multiple files and directories at the same time by listing them one by one and using spaces:
Tar-CVF filename.tar/home/mine/work/home/mine/School
The above command puts all the files in the work and school subdirectories under the/home/mine Directory into a new file named filename.tar in the current directory.
To list the contents of the TAR file, type:
Tar-tvf filename.tar
To extract the content of the TAR file, Type
Tar-xvf filename.tar
This command will not delete the tar file, but it will copy the Unarchived content to the current working directory and keep any directory structure used by the archive file. For example, if the tar file contains a file named bar.txt which is included in the foo/directory, extracting archive files will create the foo/directory in your current working directory, which contains the bar.txt File
By default, tar does not compress files.
To create a file that uses tar and bzip for archiving and compression, use the-J option:
Tar-cjvf filename. TBZ File
The preceding command creates an archive file and compresses it into a filename. TBZ file. If you use the bunzip2 command to decompress the filename. TBZ file, the filename. TBZ file will be deleted, followed by the filename.tar file.
You can also use a command to expand and release the archive bzip tar file:
Tar-xjvf filename. TBZ
To create a file archived and compressed with tar and gzip, use the-Z option:
Tar-czvf filename. tgz File
This command creates an archive file filename.tar and compresses it into a filename. tgz file (the file filename.tar is not retained ).
If you use the gunzip command to decompress the filename. tgz file, the filename. tgz file will be deleted and
Replace with filename.tar.
You can use a single command to expand the gzip tar file:
Tar-xzvf filename. tgz
The following is a classic example of online recording.
Example 1: create a full-part sub-directory file named usr.tar in the/home directory.
$ Tar CVF usr.tar/home
Example 2: complete the sub-directories in the/home directory and compress them with the name usr.tar.gz.
$ Tar czvf usr.tar.gz/home
Example 3: Restore and decompress the backup file usr.tar.gz.
$ Tar xzvf usr.tar.gz
Example 4: The contents of the usr.tar backup file are displayed on the display in split screen mode.
$ Tar tvf usr.tar | more
To back up a file to a specific device, you only need to use the device name as the backup file name.
Example 5: You can create a backup file in a floppy disk of the/dev/fd0 device and copy all the files in the/home directory to the backup file.
$ Tar CF/dev/fd0/home
To restore files on a device disk, use the xf option:
$ Tar xf/dev/fd0
Break two files into a tar package
Tar CVF log.tar log.0000000007 dbversion
1.zip a group of files with the suffix tar.gz.
# Tar CVF backup.tar/etc
# Gzip-Q backup.tar
Or
# Tar cvfz backup.tar.gz/etc/
Tar zxvf xxxx.tar.gz
Tar jxvf XXXX tar.bz2
2.release a file suffixed with tar.gz.
# Gunzip backup.tar.gz
# Tar xvf backup.tar
Or
# Tar xvfz backup.tar.gz
3. Compress With one command
# Tar CVF-/etc/| gzip-QC & amp; gt; backup.tar.gz
4. Run a command to release the instance.
# Gunzip-C backup.tar.gz | tar xvf-
5. How to unbind the tar. Z file?
# Tar xvfz backup.tar. Z
Or
# Uncompress backup.tar. Z
# Tar xvf backup.tar
6. How to unbind the. tgz file?
# Gunzip backup. tgz
7.how to compress and decompress the. bz2 package?
# Bzip2/etc/smb. conf
This will compress the smb.confinto smb.conf.bz2
# Bunzip2/etc/smb.conf.bz2
In this case, smb.conf.bz2 will be restored to smb. conf in the current directory.
Note:. bz2 compression format is not very common, you can use man Bzip2
**************************************** **************************************** * ****************************** 8
Common Linux compressed file types and decompression
Compress and package files
. Bz2-files compressed using the Bzip2 command can be decompressed using Bzip2-D filename
. GZ-files compressed using the gzip command can be unwrapped using gunzip-D filename
. Tar-use the tar package file, that is, the tarball file. You can use tar xf filename to unpack the package.
. TBZ-files compressed with the Bzip2 command after hitting the package with tar can be decompressed using tar jxf filename
. Tgz-use tar to decompress the package and then use the gzip command. You can use tar zxf filename to decompress the package.