首页   >   代码编程

Linux安装zip unzip解压工具

Windows中有很多可视化的解压工具,但是在Linux中,大多数都是命令行操作,所以相对应的也就有解压缩的命令:zipunzip,不过这个命令不是自带的,需要手动安装。

正好今天碰到一个,就给大家演示一下效果,也教一下大家如何在linux中安装zip、unzip工具。

服务器上有一个jar包,是之前打包传上去的,但是数据库却连的不对,本来应该连到线上环境,但是却连到了测试环境,但是配置文件是抽出来打包到公共的config.jar中,所以想看一下也看不到,除非将config.jar下载到本地解压再反编译,但是这样无疑浪费了太多时间,而且也很麻烦。

Linux安装zip unzip解压工具

所以,就需要有一个linux中的解压缩工具,让我们可以直接在服务器上就能看到jar中的文件,从而快速定位问题,我直接敲了一个unzip,提示脚本不存在,因为这是一台新的服务器。

[root@izbp165gqemaum7l4hq7p5z lib]# unzip config-1.0-SNAPSHOT.jar 
-bash: unzip: command not found

那我们就来安装一个,由于时间关系,没有去找二进制安装包,所以直接使用yum命令来安装:

[root@izbp165gqemaum7l4hq7p5z lib]# yum install -y unzip zip
Loaded plugins: fastestmirror
base                                                                                                                                                                | 3.6 kB  00:00:00     
epel                                                                                                                                                                | 4.7 kB  00:00:00     
extras                                                                                                                                                              | 3.4 kB  00:00:00     
updates                                                                                                                                                             | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                                                                   | 180 kB  00:00:00     
(2/4): epel/x86_64/updateinfo                                                                                                                                       | 1.0 MB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                                                                                  | 3.2 MB  00:00:00     
(4/4): epel/x86_64/primary_db                                                                                                                                       | 6.6 MB  00:00:00     
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package unzip.x86_64 0:6.0-19.el7 will be installed
---> Package zip.x86_64 0:3.0-11.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================
 Package                                    Arch                                        Version                                            Repository                                 Size
===========================================================================================================================================================================================
Installing:
 unzip                                      x86_64                                      6.0-19.el7                                         base                                      170 k
 zip                                        x86_64                                      3.0-11.el7                                         base                                      260 k

Transaction Summary
===========================================================================================================================================================================================
Install  2 Packages

Total download size: 430 k
Installed size: 1.1 M
Downloading packages:
(1/2): unzip-6.0-19.el7.x86_64.rpm                                                                                                                                  | 170 kB  00:00:00     
(2/2): zip-3.0-11.el7.x86_64.rpm                                                                                                                                    | 260 kB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                      4.7 MB/s | 430 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : zip-3.0-11.el7.x86_64                                                                                                                                                   1/2 
  Installing : unzip-6.0-19.el7.x86_64                                                                                                                                                 2/2 
  Verifying  : unzip-6.0-19.el7.x86_64                                                                                                                                                 1/2 
  Verifying  : zip-3.0-11.el7.x86_64                                                                                                                                                   2/2 

Installed:
  unzip.x86_64 0:6.0-19.el7                                                                     zip.x86_64 0:3.0-11.el7                                                                    

Complete!

基本上不会怎么报错,安装成功了之后,我们再次输入unzip命令来解压config.jar(解压到指定目录,使用 -d 参数

[root@izbp165gqemaum7l4hq7p5z lib]# unzip config-1.0-SNAPSHOT.jar -d config
Archive:  config-1.0-SNAPSHOT.jar
   creating: config/META-INF/
  inflating: config/META-INF/MANIFEST.MF  
   creating: config/spring/
  inflating: config/cos.properties   
  inflating: config/freemarker.properties  
  inflating: config/grid.properties  
  inflating: config/jdbc.properties  
  inflating: config/log4j2-1.xml     
  inflating: config/log4j2.xml       
  inflating: config/mogj.properties  
  inflating: config/money.properties  
  inflating: config/ossKey.properties  
  inflating: config/ouath2.properties  
  inflating: config/pinduoduo.properties  
  inflating: config/redis.properties  
  inflating: config/spring/mybatis-config.xml  
  inflating: config/spring/spring-init.xml  
  inflating: config/spring/spring-redis.xml  
  inflating: config/weixin.properties  
   creating: config/META-INF/maven/
   creating: config/META-INF/maven/com.wo.money/
   creating: config/META-INF/maven/com.wo.money/config/
  inflating: config/META-INF/maven/com.wo.money/config/pom.xml  
  inflating: config/META-INF/maven/com.wo.money/config/pom.properties

再次查看目录,就可以看到一个config文件夹了

Linux安装zip unzip解压工具

此时,我们就可以看到原本jar中的内容了,对于我们解决问题的效率,提高的不是一点儿半点儿!

QQ群: 686430774  /  718410762

站长Q: 1347384268

如果文章有帮到你,可以考虑请博主喝杯咖啡!

分享到:

欢迎分享本文,转载请注明出处!

作者:不忘初心

发布时间:2019-03-20

永久地址:https://www.jiweichengzhu.com/article/6a22e49cb5084698a41c7338fb349e2d

评论