In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This paper introduces the compression programs tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, rar, unrar under linux, and how to use them on .tar, .gz, .tar.gz, .tgz, .bz2, .tar.bz2, .Z,. Tar.Z, .zip, .rar, these 10 compressed files to operate
The most commonly used packaging program under Linux is tar. Packages typed by tar programs are often called tar packages, and commands for tar package files usually end with .tar. After you generate the tar package, you can compress it with other programs, so let's first talk about the basic usage of the tar command:
There are many options for the tar command (you can see them with man tar), but there are only a few commonly used options. Here's an example:
? tar-cf all.tar * .jpg
This command is to type all .jpg files into a package called all.tar. -c means to generate a new package, and-f specifies the file name of the package.
? tar-rf all.tar * .gif
This command adds all .gif files to the all.tar package. -r means to add files.
? tar-uf all.tar logo.gif
This command updates the logo.gif file in the original tar package all.tar, and-u means to update the file.
? tar-tf all.tar
This command lists all the files in the all.tar package.-t means to list files.
? tar-xf all.tar
This command unlocks all the files in the all.tar package, and-x means to unlock
These are the most basic uses of tar. In order to make it convenient for users to compress or extract files while packing and unpacking, tar provides a special function. This means that tar can call other compression programs, such as gzip, bzip2, etc., while packaging or unpacking.
1) call tar
Gzip is a compression program developed by GNU, and the file at the end of .gz is the result of gzip compression. The decompression program as opposed to gzip is gunzip. The parameter-z is used in tar to call gzip. Here is an example:
? tar-czf all.tar.gz * .jpg
This command forms all .jpg files into a tar package and compresses it with gzip to generate a gzip-compressed package named all.tar.gz
? tar-xzf all.tar.gz
This command is to unlock the package generated above.
2) tar calls bzip2
Bzip2 is a more powerful compression program, and the file at the end of .bz2 is the result of bzip2 compression.
The decompression program as opposed to bzip2 is bunzip2. The parameter-j is used in tar to call gzip. Here is an example:
? tar-cjf all.tar.bz2 * .jpg
This command forms all .jpg files into a tar package and compresses it with bzip2 to generate a bzip2-compressed package named all.tar.bz2
? tar-xjf all.tar.bz2
This command is to unlock the package generated above.
3) tar calls compress
Compress is also a compression program, but it seems that not as many people use compress as gzip and bzip2. The file at the end of .Z is the result of bzip2 compression. The decompression program as opposed to compress is uncompress. The parameter-Z is used in tar to call compress. Here is an example:
? tar-cZf all.tar.Z * .jpg
This command forms all .jpg files into a tar package and compresses it with compress to generate a uncompress-compressed package named all.tar.Z
? tar-xZf all.tar.Z
This command is to unlock the package generated above
With the above knowledge, you should be able to unlock a variety of compressed files. Here is a summary of the compressed files of the tar series:
1) for files at the end of .tar
Tar-xf all.tar
2) for files ending with .gz
Gzip-d all.gz
Gunzip all.gz
3) for files ending with .tgz or .tar.gz
Tar-xzf all.tar.gz
Tar-xzf all.tgz
4) for files at the end of .bz2
Bzip2-d all.bz2
Bunzip2 all.bz2
5) for files at the end of tar.bz2
Tar-xjf all.tar.bz2
6) for files ending with .Z
Uncompress all.Z
7) for files ending with .tar.Z
Tar-xZf all.tar.z
In addition, for the common compressed files .zip and .rar under Window, Linux also has methods to extract them:
1) for .zip
Zip and unzip programs are provided under linux. Zip is the compression program and unzip is the decompression program. There are many options for their parameters. Here is only a brief introduction, and an example is still given to illustrate their usage:
? zip all.zip * .jpg
This command compresses all .jpg files into a zip package
? 1# unzip all.zip
This command unzips all the files in all.zip
2) for .rar
To process .rar files under linux, you need to install RARfor Linux, which you can download from the Internet, but keep in mind that RARfor Linux is not free; you can download RARfor Linux 3. 2 from http://www.rarsoft.com/download.htm.
0, then install:
? 1 2 "tar-xzpvf rarlinux-3.2.0.tar.gz # cd rar # make
After installation, there are two programs: rar and unrar. Rar is the compression program and unrar is the decompression program. There are many options for their parameters. Here is only a brief introduction, and an example is still given to illustrate their usage:
? rar an all * .jpg
This command compresses all .jpg files into a rar package called all.rar, which automatically appends the .rar extension to the package name.
? 1# unrar e all.rar
This command unzips all the files in all.rar
So far, we have introduced tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, rar, unrar and other programs under linux, and you should be able to use them for .tar, .gz, .tar.gz, .tgz, .bz2, .tar.bz2. Z, .tar.Z, .zip, .rar
You should not need to worry about downloading a piece of software and not knowing how to unzip it under Linux. And the above methods are basically effective for Unix.
This paper introduces the compression programs tar, gzip, gunzip, bzip2, bunzip2, compress, uncompress, zip, unzip, rar, unrar under linux, and how to use them on .tar, .gz, .tar.gz, .tgz, .bz2, .tar.bz2, .Z,. Tar.Z, .zip, .rar, these 10 compressed files
Operation.
The following is a supplement
Tar
-c: create compressed files
-x: decompression
-t: view content
-r: appends files to the end of the compressed archive file
-u: update the files in the original package
These five are independent commands, one of which should be used for compression and decompression, which can be used with other commands, but only one of them can be used. The following parameters are optional when compressing or decompressing files as needed.
-z: with gzip attribute
-j: with bz2 attribute
-Z: with compress attribute
-v: show all processes
-O: unlock files to standard output
The following parameter-f is required
-f: use the file name and remember that this parameter is the last parameter and can only be followed by the file name.
? 1 "tar-cf all.tar *. Jpg this command is to type all .jpg files into a package called all.tar. -c means to generate a new package, and-f specifies the file name of the package. # tar-rf all.tar * .gif
This command adds all .gif files to the all.tar package. -r means to add files.
? tar-uf all.tar logo.gif
This command updates the logo.gif file in the original tar package all.tar, and-u means to update the file.
? tar-tf all.tar
This command lists all the files in the all.tar package.-t means to list files.
? tar-xf all.tar
This command unlocks all the files in the all.tar package, and-x means to unlock
Compress
Tar-cvf jpg.tar * .jpg / / package all jpg files in the directory into tar.jpg
Tar-czf jpg.tar.gz * .jpg / / package all the jpg files in the directory into jpg.tar and compress them with gzip to generate a gzip compressed package named jpg.tar.gz
Tar-cjf jpg.tar.bz2 * .jpg / / package all the jpg files in the directory into jpg.tar and compress them with bzip2 to generate a bzip2 compressed package named jpg.tar.bz2
Tar-cZf jpg.tar.Z * .jpg / / package all the jpg files in the directory into jpg.tar and compress them with compress to generate a umcompress compressed package named jpg.tar.Z
For rar a jpg.rar * .jpg / / rar format, you need to download rar for linux first.
For compression in zip jpg.zip * .jpg / / zip format, you need to download zip for linux first
Decompression
Tar-xvf file.tar / / extract the tar package
Tar-xzvf file.tar.gz / / decompress tar.gz
Tar-xjvf file.tar.bz2 / / decompress tar.bz2
Tar-xZvf file.tar.Z / / decompress tar.Z
Unrar e file.rar / / decompress rar
Unzip file.zip / / decompress zip
Summary
1. Tar is decompressed with tar-xvf
2. *. Gz is decompressed with gzip-d or gunzip
3. * .tar.gz and * .tgz are decompressed with tar-xzf
4. * .bz2 decompress with bzip2-d or bunzip2
5. * .tar.bz2 decompress with tar-xjf
6. * .Z decompress with uncompress
7. Tar.Z is decompressed with tar-xZf
8. *. Rar decompressed with unrar e
9. *. Zip decompressed with unzip
Decompress RAR software under Linux download and extract .zip and .rar files
Download address: http://www.rarsoft.com/download.htm (currently RAR 3.71for Linux)
Whichever is the latest.
For the common compressed files .zip and .rar under Window, Linux also has methods to extract them:
1: for .zip
Zip and unzip programs are provided under linux. Zip is the compression program and unzip is the decompression program. There are many options for their parameters. Here is only a brief introduction to them, with examples to illustrate their usage:
? 1 extract zip all.zip * .jpg (this command compresses all .jpg files into a zip package) # unzip all.zip (this command unzips all files in all.zip)
2: for .rar
To process .rar files under linux, you need to install RAR for Linux, which you can download from the Internet, but remember, RAR for Linux is not free; you can download RAR 3 from http://www.rarsoft.com/download.htm. 60 for Linux, and then install it as follows:
? 1 2 "tar-xzpvf rarlinux-3.2.0.tar.gz # cd rar # make
After installation, there are two programs: rar and unrar. Rar is the compression program and unrar is the decompression program. They have a lot of parameter options, so give an example to illustrate their usage.
? rar an all * .jpg
This command compresses all .jpg files into a rar package called all.rar, which automatically appends the .rar extension to the package name.
? 1# unrar e all.rar
This command unzips all the files in all.rar.
The xxxx.tar.gz file uses tar with the zxvf parameter, which can be unzipped at once. XXXX is the file name. For example:
? 1$ tar zxvf xxxx.tar.gz
Gzip-d
Grammar: gzip [- acdfhlLnNqrtvV] [- S] [-] [--best/fast] [file.] Or gzip [- acdfhlLnNqrtvV] [- S] [-] [--best/fast] [directory]
Additional note: gzip is a widely used compression program, after the file is compressed, its name will be followed by the ".gz" extension.
Parameters:
-an or-- ascii uses ASCII text mode.
-c or-- stdout or-- to-stdout outputs the compressed file to a standard output device without changing the original file.
-d or-- decompress or-uncompress unpack the compressed file.
-f or-- force forcibly compress the file. Regardless of whether the file name or hard connection exists and whether the file is a symbolic link.
-h or-- help online help.
-l or-- list lists information about the compressed file.
-L or-- license displays version and copyright information.
When-n or-- no-name compresses a file, the original file name and timestamp are not saved.
When-N or-- name compresses the file, saves the original file name and timestamp.
-Q or-- quiet does not display a warning message.
-r or-- recursive recursive processing, processing all files and subdirectories under the specified directory together.
-S or-suffix changes the compressed suffix string.
-t or-- test tests whether the compressed file is correct.
-v or-- verbose shows the instruction execution process.
-V or-- version displays version information.
-Compression efficiency is a value between 1Mui 9 and the default value is "6". The higher the specified value, the higher the compression efficiency.
-- best this parameter has the same effect as specifying the "- 9" parameter.
-- fast this parameter has the same effect as specifying the "- 1" parameter.
1. Tar is decompressed with tar-xvf
2. *. Gz is decompressed with gzip-d or gunzip
3. * .tar.gz and * .tgz are decompressed with tar-xzf
4. * .bz2 decompress with bzip2-d or bunzip2
5. * .tar.bz2 decompress with tar-xjf
6. * .Z decompress with uncompress
7. Tar.Z is decompressed with tar-xZf
8. *. Rar decompressed with unrar e
9. *. Zip decompressed with unzip
Decompression command of * .tar.gz file under Linux
1. Compression command:
Command format: tar-zcvf compressed file name. Tar.gz compressed file name
You can switch to the current directory first. Both compressed file name and compressed file name can be added to the path.
two。 Extract command:
Command format: tar-zxvf compressed file name. tar.gz
Unzipped files can only be placed in the current directory.
You can use the zip command to process multiple files and directories at the same time by listing them one by one and spacing them with spaces:
Zip-r filename.zip file1 file2 file3 / usr/work/school
Compress a single directory command zip-r filename.zip filename
The above command compresses the contents of the file1, file2, file3, and / usr/work/school directories (assuming this directory exists) and puts them in the filename.zip file.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.