安裝方式:
1、通過yum下載進行安裝 yum -y install unzip
2、通過rpm包進行離線安裝
unzip:
CentOS6:http://mirror.centos.org/centos/6/os/x86_64/Packages/unzip-6.0-5.el6.x86_64.rpm
CentOS7:http://mirror.centos.org/centos/7/os/x86_64/Packages/unzip-6.0-20.el7.x86_64.rpm
zip:
CentOS6:http://mirror.centos.org/centos/6/os/x86_64/Packages/zip-3.0-1.el6_7.1.x86_64.rpm
CentOS7:http://mirror.centos.org/centos/7/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm
常使用參數:
-r 備份目錄參數
-d 解壓到指定的目錄下
-v 不解壓只查看壓縮包裏的內容
-t 驗證壓縮包是否完整
-j 把壓縮包裏所有的文件解壓到第一級目錄
-m 將文件壓縮並加入壓縮文件後,刪除源文件
-q 不顯示壓縮執行過程
-n 排除指定文件名後綴的文件
-P 給壓縮包添加解壓密碼
CentOS6和7離線安裝:
unzip:
[root@node1 ~]# unzip
-bash: unzip: command not found
[root@node1 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@node1 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/unzip-6.0-20.el7.x86_64.rpm
--2019-11-28 08:40:41-- http://mirror.centos.org/centos/7/os/x86_64/Packages/unzip-6.0-20.el7.x86_64.rpm
Resolving mirror.centos.org... 160.116.15.22, 2401:78c0::e00e
Connecting to mirror.centos.org|160.116.15.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 173712 (170K) [application/x-rpm]
Saving to: “unzip-6.0-20.el7.x86_64.rpm”
100%[===================================================================================================================================================>] 173,712 150K/s in 1.1s
2019-11-28 08:40:43 (150 KB/s) - “unzip-6.0-20.el7.x86_64.rpm” saved [173712/173712]
[root@node1 ~]# rpm -ivh unzip-6.0-20.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:unzip-6.0-20.el7 ################################# [100%]
[root@node1 ~]# unzip
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment only
-v list verbosely/show version info -T timestamp archive to latest
-x exclude files that follow (in xlist) -d extract files into exdir
modifiers:
-n never overwrite existing files -q quiet mode (-qq => quieter)
-o overwrite files WITHOUT prompting -a auto-convert any text files
-j junk paths (do not make directories) -aa treat ALL files as text
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through "more" pager
-O CHARSET specify a character encoding for DOS, Windows and OS/2 archives
-I CHARSET specify a character encoding for UNIX and other archives
See "unzip -hh" or unzip.txt for more help. Examples:
unzip data1 -x joe => extract all files except joe from zipfile data1.zip
unzip -p foo | more => send contents of foo.zip via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
[root@node1 ~]#
zip:
[root@node1 ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm
--2019-11-28 08:52:32-- http://mirror.centos.org/centos/7/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm
Resolving mirror.centos.org... 160.116.15.22, 2401:78c0::e00e
Connecting to mirror.centos.org|160.116.15.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 266160 (260K) [application/x-rpm]
Saving to: “zip-3.0-11.el7.x86_64.rpm”
100%[===================================================================================================================================================>] 266,160 25.9K/s in 9.9s
2019-11-28 08:52:42 (26.3 KB/s) - “zip-3.0-11.el7.x86_64.rpm” saved [266160/266160]
[root@node1 ~]# rpm -ivh zip-3.0-11.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:zip-3.0-11.el7 ################################# [100%]
[root@node1 ~]#
示例:
壓縮pg_backup目錄 壓縮包名爲pg_bak.zip
查看壓縮包裏的信息:
解壓到指定的目錄下:
給壓縮包添加解壓密碼: