Fedora Linux 升级系统中的 7-Zip
早上四哥 (scz) 发了条微博,7-Zip 最近有相关的CVE,CVE-2025-11001、CVE-2025-11002,建议升级到 25.01。
如果使用 Windows 系统,在 https://7-zip.org/ 下载 7-Zip 25.01,升级安装即可。
在 Linux 系统中 7-zip 的版本比较复杂,关于 p7zip 和 7-zip 可以参考7-zip 官方readme.txt 的说明。
7-Zip and p7zip
===============
Now there are two different ports of 7-Zip for Linux/macOS:
1) p7zip - another port of 7-Zip for Linux, made by an independent developer.
The latest version of p7zip now is 16.02, and that p7zip 16.02 is outdated now.
2) 7-Zip for Linux/macOS - this package - it's new code with all changes from latest 7-Zip for Windows.
These two ports are not identical.
Note also that some Linux specific things can be implemented better in p7zip than in new 7-Zip for Linux.
There are several main executables in 7-Zip and p7zip:
7zz (7-Zip) - standalone full version of 7-Zip that supports all formats.
7zzs (7-Zip) - standalone full version of 7-Zip that supports all formats (static library linking).
7z (p7zip) - 7-Zip that requires 7z.so shared library, and it supports all formats via 7z.so.
7zr (p7zip) - standalone reduced version of 7-Zip that supports some 7-Zip's formats:
7z, xz, lzma and split.
7za (p7zip) - standalone version of 7-Zip that supports some main formats:
7z, xz, lzma, zip, bzip2, gzip, tar, cab, ppmd and split.
7zzs is similar to 7zz, but 7zzs was compiled for static library linking,
so 7zzs does not use external shared library (".so") files.
You can use 7zzs, if 7zz does not work due to lack of required shared library (".so") files.
The command line syntax for executables from p7zip is similar to 7zz syntax from this package.
The manual of 7-Zip and p7zip can show `7z` in command examples.
But you can use `7zz`, `7zr`, `7za` instead of `7z` from examples.
实在是有点混乱,7-Zip 官方为了和 p7zip 的二进制文件区别,引入了 7zz 和 7zzs。
看看 Fedora Linux 的情况:
$ dnf search 7z
Matched fields: name, summary
p7zip-gui.x86_64 7zG - 7-Zip GUI version
p7zip-plugins.x86_64 Additional plugins for p7zip
python3-extractcode-7z.noarch ScanCode Toolkit plugin to use pre-installed 7zip executables
Matched fields: name
p7zip.x86_64 Very high compression ratio file archiver
p7zip-doc.noarch Manual documentation and contrib directory
Matched fields: summary
golang-github-kjk-lzmadec.x86_64 Decompress .7z files in Go using 7z executable
golang-github-kjk-lzmadec-devel.noarch Decompress .7z files in Go using 7z executable
Fedora Linux 官方的软件仓库中,没有 7zip 只有 p7zip 。p7zip 已经很久没有更新过了,参见:
https://sourceforge.net/projects/p7zip/files/p7zip/
检查 Fedora 系统中, 7z 的版本。
$ /usr/bin/7z i
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 ...
版本非常古老了,卸载 p7zip,免得以后出现问题。
sudo dnf remove p7zip
执行 dnf remove p7zip
后, /usr/bin/7z
居然没有删除,只好使用 dnf provides
查看 7z 是那个软件包提供的。
sudo dnf provides 7z
p7zip-plugins-16.02-32.fc42.x86_64 : Additional plugins for p7zip
Repo : @System
Matched From :
Filename : /usr/bin/7z
p7zip-plugins-16.02-32.fc42.x86_64 : Additional plugins for p7zip
Repo : fedora
Matched From :
Filename : /usr/bin/7z
/usr/bin/7z
/usr/lib/.build-id/8c/a62e905852cf8576d9686792c13e968b50d498
/usr/lib/.build-id/a0/7a5306a2c92c1c8c662c03f8d8b3e3687e455d
/usr/libexec/p7zip/7z
/usr/libexec/p7zip/7z.so
/usr/share/man/man1/7z.1.gz
比较意外,p7zip-plugins 提供了 /usr/bin/7z ,将其卸载看看 sudo dnf remove p7zip-plugins
sudo dnf remove p7zip-plugins
Package Arch Version Repository Size
Removing:
p7zip-plugins x86_64 16.02-32.fc42 fedora 2.7 MiB
Removing dependent packages:
ark x86_64 25.08.1-1.fc42 updates 3.3 MiB
Removing unused dependencies:
ark-libs x86_64 25.08.1-1.fc42 updates 1.8 MiB
gnustep-base-libs x86_64 1.30.0-7.fc42 fedora 8.0 MiB
libobjc x86_64 15.2.1-1.fc42 updates 91.7 KiB
unar x86_64 1.10.8-10.fc42 fedora 4.7 MiB
Transaction Summary:
Removing: 6 packages
Fedora 下的解压软件对 p7zip-plugins
依赖比较严重,只能使用 rpm 命令删除。
sudo rpm -e --nodeps p7zip-plugins
检查一下 /usr/bin/7z
是否已经删除了。
ls /usr/bin/7z
ls: 无法访问 '/usr/bin/7z': 没有那个文件或目录
接下来需要升级 7-zip,在 Linux 系统中升级 7zip 通用的方法,是到官方网站下载编译好的 7-zip 二进制程序。
(其他不同架构可以在 https://7-zip.org/download.html 页面查找下载链接)
wget https://7-zip.org/a/7z2501-linux-x64.tar.xz
解压 7z2501-linux-x64.tar.xz 后,可以发现有两个二进制程序 7zz 和 7zzs。
- 7zz - standalone console version of 7-Zip (version compiled for dynamic system library linking)
- 7zzs - standalone console version of 7-Zip (version compiled with static system library linking)
然后利用路径优先级,可以在使用命令行时,使用升级过的 7z。
sudo cp 7zzs /usr/bin/7z
export PATH=/usr/local/bin/:$PATH
我在 Fedora 上使用 Ark 解压文件,测试解压 .7z 压缩包文件正常。
Ark 的 7-Zip plugin 使用的是 7z 二进制,同时支持 p7zip 和 官方的 7-zip 提供的二进制程序。
参见: https://invent.kde.org/utilities/ark/-/blob/release/25.08/plugins/cli7zplugin/cliplugin.cpp
7-Zip plugin: supports the 7-Zip format by using the 7z binary.
先这样,目前看系统中缺少 7z.so
,等遇上问题再说。