linux command - compression and packaging

Common compression format in Linux can recognize a dozen, such as ".zip" ".gz" ".bz2" ".tar" ".tar.gz" ".tar.bz2" and so on.

1, zip format

".Zip" Windows is the most popular compression formats, Linux can correctly identify the ".zip" format, which can be easily and Windows systems common compressed file.

1.1zip compression format command

Command name: zip
English original intent: files package and compress (archive)
path where: / usr / bin / zip
execute permissions: All users
Description: compressed files or directories

[root@love2 ~]# zip [选项] 压缩包名 源文件或源目录 
选项:  
-r:  压缩目录
[root@love2 ~]# zip -r  test.zip test test.txt 
  adding: test/ (stored 0%)
  adding: test.txt (stored 0%)
1.2zip decompression command format

Command name: unzip.
English original intent: list, test and extract compressed files in a ZIP archive.
The path: / usr / bin / unzip.
Execute permissions: All users.
Description: File file list, test and extract compressed.

[root@love2 ~]# unzip [选项] 压缩包名 
选项:  -d:  指定解压缩位置 
[root@love2 ~]# unzip test.zip -d /tmp/
Archive:  test.zip
   creating: /tmp/test/
 extracting: /tmp/test.txt  
2, ". Gz" format
2.1. ".Gz" compressed format command

Command name: gzip.
English original intent: compress or expand files.
The path: / bin / gzip.
Execute permissions: All users.
Description: compressed files or directories

[root@love2 ~]# gzip [选项] 源文件 
选项:  
-c:  将压缩数据输出到标准输出中,可以用于保留源文件  
-d:  解压缩  
-r:  压缩目录

[root@love2 ~]# gzip test.txt 
2.2. ".Gz" de-compression format command

If you want to decompress ".gz" format, then use "gzip -d archive" and "gunzip archive" command can be.
Command name: gunzip
English original intent: compress or expand files.
The path: / bin / gunzip.
Execute permissions: All users.
Description: Unzip the file or directory.

[root@love2 ~]# gunzip test.txt.gz 
[root@love2 ~]# gzip -d test.txt.gz  
3. ".Bz2" format

.bz2 "Linux Format is another compression format, in theory," bz2 "algorithm format is more advanced, higher compression ratio; and". .gz "format relatively compressed time faster.

3.1. ".Bz2" compression format command

Command name: bzip2.
English original intent: a block-sorting file compressor
path where: / usr / bin / bzip2
execute permissions: All users
Description: only compressed file

[root@love2 ~]# bzip2 [选项] 源文件 
选项:  
-d:  解压缩  
-k:  压缩时,保留源文件  
-v:  显示压缩的详细信息 
[root@love2 ~]# bzip2 edu.txt #压缩成.bz2格式 
[root@love2 ~]# bzip2 -k edu.txt  #保留源文件压缩 
3.2. Solution ".bz2" compression format command

"The .bz2" format can be "bzip2 -d compressed" command to decompress and to be used "Bunzip2 compressed" command to decompress.
Command name: bunzip2.
English original intent: a block-sorting file compressor.
The path: / usr / bin / bunzip2.
Execute permissions: All users.
Description: solution .bz2 compressed format command.
[root@love2 ~]# bunzip2 edu.txt.bz2 [root@love2 ~]# bzip2 -d edu.txt.bz2

4. ".Tar" format

".Tar" reconciliation package packaging format are using the tar command above, except for options.

4.1. ".Tar" format packaging commands

Name command: tar
English original intent: tar
path where: / bin / tar
execute permissions: All users
Description: packing, not compressed.

[root@love2 ~]# tar [选项] [-f 压缩包名] 源文件或目录 
-c:打包  
-f:  指定压缩包的文件名。压缩包的扩展名是用来给管理员识别格式的,所以一定要正确指定扩展名  
-v:  显示打包文件过程 
-z:   以gz格式压缩
-j:   以.bz2格式压缩

[root@love2 ~]# tar -jcvf edu.tar.bz2 edu.txt #以.bz2格式先压缩,再打包。 
4.2. Solution ".tar" format packaging commands

".Tar" format solution packaging also need to use the tar command, but the options are not the same

[root@l0ve2 ~]# tar [选项] 压缩包 
选项:  -x:   解打包  
-f:   指定压缩包的文件名   
-v:   显示解打包文件过程  
-t:   测试,就是不解打包,只是查看包中有哪些文件
-C:    指定解压路劲 
[root@love2 ~]# tar -jxvf edu.tar.bz2 解打包

Guess you like

Origin www.cnblogs.com/hjnzs/p/11933967.html