Linux.tar .gz .tgz .bz2 .bz and other solutions, pressure pack command detailed

  
 One, tar command

tar can create files for files and directories. With tar, users can create files (backup files) for a particular file, change files in a file, or add new files to a file. Tar was originally used to create files on tape, and now users can create files on any device, such as floppy disks. With the tar command, you can package a whole bunch of files and directories into one file, which is very useful for backing up files or combining several files into one file for network transmission. The tar on Linux is the GNU version. Syntax: tar [main option + sub-option] file or directory When using this command, the main option is mandatory. It tells tar what to do. The auxiliary option is auxiliary and can be used. Main Options:
c :
Create a new archive. If the user wants to back up a directory or some files, choose this option. r :
Append the file to be archived to the end of the archive. For example, if the user has already made a backup file and finds that there is still a directory or some files forgotten to back up, you can use this option to append the forgotten directory or file to the backup file. t:
List the contents of the archive and see which files have been backed up. u:
Update the file. That is to say, the original backup file is replaced with the newly added file, and if the file to be updated is not found in the backup file, it is appended to the end of the backup file. x:
Release the file from the archive. Auxiliary options: b:
This option is set for the tape drive. It is followed by a number to indicate the size of the block. The system default is 20 (20*512 bytes). f:
Using an archive or device, this option is usually required. k:
Save an existing file. For example, we restore a file, and during the restore process, we encounter the same file and will not overwrite it. m:
When restoring files, set the modification time of all files to now. M:
M is used to create multi-volume archives for storage on several disks. v:
Detailed report of file information processed by tar. If you do not have this option, tar does not report file information. w:
Every step requires confirmation. z:
Use gzip to compress/decompress files. After adding this option, you can compress the archive file, but you must use this option to decompress it when restoring. Second, Linux
Analysis of compressed files

For those who are new to Linux, Linux will definitely give Linux a large variety of file names. Give a dizzy. Let's not say anything, just compress files as an example. We know that there are only two common types of compressed files under Windows
, one is zip and the other is .rap. However, Linux is different. It has many compressed file names such as .gz, .tar.gz, tgz, bz2, .Z, .tar, etc. In addition, .zip and .rar under Windows can also be used under Linux, but in There are too few people using .zip and .rar on Linux. This article will summarize some of these common compressed files, I hope that you will not be confused when you encounter these files next time. Before summarizing the various types of compressed files, we must first clarify two concepts: packaging and compression
. Packing refers to turning a bunch of files or directories into a total file. Compression is to convert a large file into a small file through some compression algorithm. Why distinguish these two concepts? In fact, this is due to the fact that many compression programs in Linux can only compress one file, so when you want to compress a large number of files, you must first use the other tool to make this large file into a package. Then compress the original compression program. The most commonly used packager under Linux is tar. The package that is written using the tar program is often called a tar package. The commands for tarball files usually end with .tar. After generating the tarball, you can use other programs to compress, so first talk about the basic usage of the tar command: There are many options for the tar command (you can view it with man tar), but the common ones are just a few Options, here's an example: # tar -cf all.tar *.jpg
This command is to make all .jpg files into a package called all.tar. -c indicates that a new package is generated, 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 a file. # tar -uf all.tar logo.gif
This command updates the logo.gif file in the original tarball all.tar, and -u means the update file. # tar -tf all.tar
This command lists all the files in the all.tar package, -t is the meaning of the listed files # tar -xf all.tar
This one The command is to solve all the files in the all.tar package, and the -x is the meaning of the solution. The above is the most basic usage of tar. In order to facilitate the user to compress or decompress files while packaging and unpacking, tar provides a special feature. This is where tar can call other compression programs at the same time as packaging or unpacking, such as calling gzip, bzip2, and so on. 1) tar
call
gzip
gzip is a compression program developed by the GNU organization. The file ending with .gz is the result of gzip compression. The decompression program opposite gzip is gunzip. Use the -z parameter in tar to call gzip. Here's an example: # tar -czf all.tar.gz *.jpg This command is to convert all .jpg files into a tarball and compress it with gzip to generate a gzip-compressed package. Named all.tar.gz # tar -xzf all.tar.gz This command is to unpack the package generated above. 2) tar
call
bzip2
bzip2 is a compression program with a stronger compression capability. The file ending with .bz2 is the result of bzip2 compression. The decompression program opposite bzip2 is bunzip2. Use the -j parameter in tar to call gzip. Here's an example: # tar -cjf all.tar.bz2 *.jpg This command is to convert all .jpg files into a tarball and compress it with bzip2 to generate a bzip2 compressed package. Named all.tar.bz2 # tar -xjf all.tar.bz2 This command is to unpack the package generated above.
3)tar


compress
compress is also a compression program, but it seems that people who use compress are not as good as gzip and bzip2. The .Z ending file is the result of bzip2 compression. The decompression program opposite to compress is uncompress. Use the -Z parameter in tar to call gzip. Here's an example: # tar -cZf all.tar.Z *.jpg This command is to make all .jpg files into a tarball, and compress it with compress to generate an uncompress-compressed package. Named all.tar.Z # tar -xZf all.tar.Z This command is to unlock the above generated package. With the above knowledge, you should be able to unlock a variety of compressed files, the following compression for the tar series Make a summary of the file: 1)
For files ending in .tar

tar -xf all.tar 2)
For. Gz ending file

gzip -d all.gz gunzip all.gz 3)
for .tgz or .tar.gz ending files

tar -xzf all.tar.gz tar -xzf all.tgz 4)
For files ending in .bz2

bzip2 -d all.bz2 Bunzip2 all.bz2 5)
Files ending with tar.bz2
tar -xjf all.tar.bz2 6)
For files ending in .Z

uncompress all.Z 7)
Files ending with .tar.Z
tar -xZf all.tar.z Additional for Window Common compressed files .zip and .rar, Linux also has a corresponding method to solve They are: 1) For the
.zip
linux zip and unzip program provides, zip is a compression program, unzip a decompression program. They have a lot of parameter options. Here is a brief introduction. Here is an example to illustrate their usage: # zip all.zip *.jpg This command compresses all .jpg files into a zip package # unzip all.zip This command Is to extract all the files in all.zip
Copyright © Windows knowledge All Rights Reserved