【CentOS】Linux离线安装zip和unzip

背景

因工作原因,经常需要拉取服务器(CentOS7.9)的日志文件,有些日志文件的大小在2G以上,甚至7、8G以上,再加上网络限速,从服务器直接下载该日志文件耗时太久,考虑将日志文件压缩后再下载。

使用zip命令,报command not found,故安装zip和unzip。

安装步骤

步骤1:下载安装包后,上传至服务器的指定文件夹

网上下载好rpm文件(zip-3.0-11.el7.x86_64.rpmunzip-6.0-21.el7.x86_64.rpm),上传到服务器指定文件夹,这里是上传到 /usr/local 文件夹

zip工具下载地址unzip工具下载地址

步骤2:使用如下命令安装

[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@localhost ~]# cat /proc/version 
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020

[root@localhost ~]# cd /usr/local/

[root@localhost local]# ls -lh
total 436K
drwxr-xr-x. 2 root root    6 Apr 11  2018 bin
drwxr-xr-x. 2 root root    6 Apr 11  2018 etc
drwxr-xr-x. 2 root root    6 Apr 11  2018 games
drwxr-xr-x. 2 root root    6 Apr 11  2018 include
drwxr-xr-x. 2 root root    6 Apr 11  2018 lib
drwxr-xr-x. 2 root root    6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root    6 Apr 11  2018 libexec
drwxr-xr-x. 2 root root    6 Apr 11  2018 sbin
drwxr-xr-x. 5 root root   49 Jan 10  2024 share
drwxr-xr-x. 2 root root    6 Apr 11  2018 src
-rw-r--r--. 1 root root 172K Oct 10 11:25 unzip-6.0-21.el7.x86_64.rpm
lrwxrwxrwx. 1 root root   38 Jan 10  2024 VMOptimizationTools -> /usr/local/VMOptimizationTools_2.126.5
drwxr-xr-x. 9 root root 4.0K Jun  7  2024 VMOptimizationTools_2.126.5
drwx------. 3 root root   19 Jan 10  2024 VMOptimizationToolsConfig
drwxr-xr-x. 2 root root    6 Jun  8  2024 VMOptimizationToolsLinuxTemp
drwxr-xr-x. 2 root root    6 Jun  7  2024 VMOptimizationToolsVmconfigTemp
-rw-r--r--. 1 root root 260K Oct 10 11:25 zip-3.0-11.el7.x86_64.rpm

[root@localhost local]# rpm -ivh zip-3.0-11.el7.x86_64.rpm
warning: zip-3.0-11.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zip-3.0-11.el7                   ################################# [100%]
    
[root@localhost local]# rpm -ivh unzip-6.0-21.el7.x86_64.rpm 
warning: unzip-6.0-21.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:unzip-6.0-21.el7                 ################################# [100%]
    
[root@localhost local]# rpm -q zip
zip-3.0-11.el7.x86_64

[root@localhost local]# rpm -q unzip
unzip-6.0-21.el7.x86_64

[root@localhost local]# zip
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help
posted @ 2025-10-10 12:37  K89  阅读(55)  评论(0)    收藏  举报