Centos7中使用7zip压缩工具
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,7-Zip是一个支持7z(它实现了LZMA压缩算法,具有非常高的压缩比)、LZMA2、XZ、ZIP、Zip64、CAB、ARJ、GZIP、BZIP2、TAR、CPIO、RPM、ISO、大多数文件系统映
千家信息网最后更新 2025年12月02日Centos7中使用7zip压缩工具
环境
| 7-Zip是一个支持7z(它实现了LZMA压缩算法,具有非常高的压缩比)、LZMA2、XZ、ZIP、Zip64、CAB、ARJ、GZIP、BZIP2、TAR、CPIO、RPM、ISO、大多数文件系统映像和DEB格式的文件归档器。RAR格式由于不是免费许可,已经被删除了。 |
- Centos7.7 Minimal
- p7zip-16.02
默认Centos7没有安装p7zip安装包,默认源里面也没有这个安装包,需要安装epel源才能安装p7zip安装包。
[root@localhost ~]# yum -y install epel-release[root@localhost ~]# yum -y install p7zip p7zip-plugins使用方法
7z 命令提供的函数字母与 命令行选项类似,但使用时不使用 -。这些参数字母告诉命令它需要执行的函数。
压缩文件创建一个压缩包使用 a参数
创建一个7z格式的压缩包:
[root@localhost ~]# 7z a files.7z file1.txt file2.txt file3.txt file4.txt 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive:4 files, 0 bytesCreating archive: files.7zItems to compress: 4 Files read from disk: 0Archive size: 143 bytes (1 KiB)Everything is Ok
执行完命令,查看一下是否已经创建7z格式的压缩包
创建一个包含目录的压缩包:
[root@localhost ~]# 7z a gpg.7z .gnupg/7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive:2 folders, 5 files, 8280 bytes (9 KiB)Creating archive: gpg.7zItems to compress: 7 Files read from disk: 2Archive size: 4157 bytes (5 KiB)Everything is Ok[root@localhost ~]#

7zip还可以压缩、解压缩其他格式的压缩包。比如:创建一个.zip格式的压缩包。
[root@localhost ~]# 7z a files.zip file{1..4}.txt7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive:4 files, 0 bytesCreating archive: files.zipItems to compress: 4 Files read from disk: 4Archive size: 542 bytes (1 KiB)Everything is Ok列出压缩包里面的内容列出压缩包的内容使用 l参数:
[root@localhost ~]# 7z l gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive for archives:1 file, 4157 bytes (5 KiB)Listing archive: gpg.7z--Path = gpg.7zType = 7zPhysical Size = 4157Headers Size = 278Method = LZMA2:12kSolid = +Blocks = 1 Date Time Attr Size Compressed Name------------------- ----- ------------ ------------ ------------------------2020-01-04 18:24:05 D.... 0 0 .gnupg2020-01-04 18:22:36 D.... 0 0 .gnupg/private-keys-v1.d2020-01-04 18:24:48 ....A 0 0 .gnupg/S.gpg-agent2020-01-04 18:22:36 ....A 0 0 .gnupg/pubring.gpg2020-01-04 18:24:05 ....A 0 0 .gnupg/secring.gpg2020-01-04 18:22:36 ....A 7680 3879 .gnupg/gpg.conf2020-01-04 18:24:52 ....A 600 .gnupg/random_seed------------------- ----- ------------ ------------ ------------------------2020-01-04 18:24:52 8280 3879 5 files, 2 folders解压文件
使用 e来解压文件,解压所有文件到当前目录。(不推荐使用)
[root@localhost test]# 7z e gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive for archives:1 file, 4157 bytes (5 KiB)Extracting archive: gpg.7z--Path = gpg.7zType = 7zPhysical Size = 4157Headers Size = 278Method = LZMA2:12kSolid = +Blocks = 1Everything is OkFolders: 2Files: 5Size: 8280Compressed: 4157
可以看到所有文件都解压到当前目录了。
现在使用 x参数解压文件看一下。
[root@localhost test]# 7z x gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive for archives:1 file, 4157 bytes (5 KiB)Extracting archive: gpg.7z--Path = gpg.7zType = 7zPhysical Size = 4157Headers Size = 278Method = LZMA2:12kSolid = +Blocks = 1Everything is OkFolders: 2Files: 5Size: 8280Compressed: 4157
可以看到解压出来的文件,按照原来文件的目录形式解压出来的。
一段时间之后,需要将一些新文件添加到文件夹中,并且希望将他们添加到压缩包里面,可以不用创建一个新的压缩包,只需要更新现有的压缩包就可以。
首先将test目录压缩
[root@localhost test]# 7z a files.7z test/7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive:1 folder, 4 files, 0 bytesCreating archive: files.7zItems to compress: 5 Files read from disk: 0Archive size: 158 bytes (1 KiB)Everything is Ok
在test文件夹中创建几个文件,然后再更新压缩包:
[root@localhost test]# touch test/file{5..10}.txt[root@localhost test]# 7z u files.7z test/7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Open archive: files.7z--Path = files.7zType = 7zPhysical Size = 158Headers Size = 158Solid = -Blocks = 0Scanning the drive:1 folder, 10 files, 0 bytesUpdating archive: files.7zItems to compress: 7 Files read from disk: 0Archive size: 186 bytes (1 KiB)Everything is Ok
查看一下是否已经添加文件。
[root@localhost test]# 7z l files.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI)Scanning the drive for archives:1 file, 186 bytes (1 KiB)Listing archive: files.7z--Path = files.7zType = 7zPhysical Size = 186Headers Size = 186Solid = -Blocks = 0 Date Time Attr Size Compressed Name------------------- ----- ------------ ------------ ------------------------2020-03-11 14:24:54 D.... 0 0 test2020-03-11 14:18:22 ....A 0 0 test/file1.txt2020-03-11 14:24:54 ....A 0 0 test/file10.txt2020-03-11 14:18:22 ....A 0 0 test/file2.txt2020-03-11 14:18:22 ....A 0 0 test/file3.txt2020-03-11 14:18:22 ....A 0 0 test/file4.txt2020-03-11 14:24:54 ....A 0 0 test/file5.txt2020-03-11 14:24:54 ....A 0 0 test/file6.txt2020-03-11 14:24:54 ....A 0 0 test/file7.txt2020-03-11 14:24:54 ....A 0 0 test/file8.txt2020-03-11 14:24:54 ....A 0 0 test/file9.txt------------------- ----- ------------ ------------ ------------------------2020-03-11 14:24:54 0 0 10 files, 1 folders总结
7z格式的压缩比例比ZIP格式的压缩比例高30%-50%。
文件
格式
目录
参数
命令
更新
内容
函数
字母
文件夹
比例
不用
使用方法
形式
方法
时间
映像
环境
算法
系统
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
最新网络安全整体形势
爱思服务器的软件安全吗
sql数据库员工库题
腾讯云数据库修改配置文件
学校网络安全培训工作简报
网络安全技术的实际应用
通信网络安全工程专业
网络安全 强化队伍建设
命令行看数据库数据
linux服务器怎么新建用户
软件开发技术交流
数据库并发一致性
无法连接到报表服务器
三级数据库画图工具
互联网科技怎么发展
服务器4个网口都干什么用
图片服务器 nginx
软件开发工作程序
网络安全指通过采取
昆明网站的数据库用什么设计
数据库去重复
软件开发及设备购销合同
shell脚本备份数据库
数据库标签选项
光功率预测系统属于服务器吗
查看服务器数据库命令
网络安全法保护机制
测试网络技术人员
大唐盛世软件开发鞋
地理信息系统数据库心得