pao*_*les 23 package-management apt
我不小心删除了软件包/usr/bin/test,现在无法更新、升级和安装软件包。
我已经在这里尝试了解决方案:apt-get raises /usr/bin/test: Permission returned,但这是我得到的输出:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
java-common libutempter0
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 29 not upgraded.
Need to get 1,353 kB of archives.
After this operation, 0 B of additional disk space will be used.
Ign:1 http://ph.archive.ubuntu.com/ubuntu impish/main amd64 coreutils amd64 8.32-4ubuntu2
Ign ...
Ign ...
Err:1 http://ph.archive.ubuntu.com/ubuntu impish/main amd64 coreutils amd64 8.32-4ubuntu2
Could not connect to ph.archive.ubuntu.com:80 (202.79.184.254), connection timed out
E: Failed to fetch http://ph.archive.ubuntu.com/ubuntu/pool/main/c/coreutils/coreutils_8.32-4ubuntu2_amd64.deb Could not connect to ph.archive.ubuntu.com:80 (202.79.184.254), connection timed out
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Run Code Online (Sandbox Code Playgroud)
我也尝试sudo apt update --fix-missing并得到了这个输出:
Err:8 http://ph.archive.ubuntu.com/ubuntu impish InRelease
Could not connect to ph.archive.ubuntu.com:80 (202.79.184.254), connection timed out
Err:9 http://ph.archive.ubuntu.com/ubuntu impish-updates InRelease
Unable to connect to ph.archive.ubuntu.com:http:
Err:10 http://ph.archive.ubuntu.com/ubuntu impish-backports InRelease
Unable to connect to ph.archive.ubuntu.com:http:
Fetched 125 kB in 37s (3,339 B/s)
sh: 1: /usr/bin/test: not found
sh: 1: /usr/bin/test: not found
sh: 1: /usr/bin/test: not found
Reading package lists... Done
Run Code Online (Sandbox Code Playgroud)
请帮我。
ste*_*ver 52
您可以使用test提供的命令行开关busybox来临时替换丢失的/usr/bin/test二进制文件。
首先,检查您是否有 busybox,并且它是否test正常工作:
$ /usr/bin/busybox test -x /usr/bin/busybox && echo Works
Works
Run Code Online (Sandbox Code Playgroud)
然后创建一个符号链接:
$ sudo ln -s busybox /usr/bin/test
$
$ file /usr/bin/test
/usr/bin/test: symbolic link to busybox
Run Code Online (Sandbox Code Playgroud)
然后重新安装该coreutils软件包,这将使用正确的二进制实现覆盖符号链接。
如果您没有busybox,您甚至可以创建/usr/bin/test为 shell 脚本并利用 shell 的test内置命令:
#!/bin/sh
test "$@"
Run Code Online (Sandbox Code Playgroud)
(不要忘记使其可执行, )之后chmod +x /usr/bin/test再次重新安装。coreutils
Val*_*ina 37
我能想到的最简单的解决方案,不使用包管理器(因为它不再工作):
下载 coreutils 包:
wget http://de.archive.ubuntu.com/ubuntu/pool/main/c/coreutils/coreutils_8.32-4ubuntu2_amd64.deb
Run Code Online (Sandbox Code Playgroud)
注意:如果您没有安装 wget,请使用浏览器。另请注意,确切的名称截至 2022 年 1 月 - 如果您需要在以后执行此操作,文件名很可能会发生更改以反映更新的包。
解压下载的包
dpkg-deb -R coreutils_8.32-4ubuntu2_amd64.deb coreutils_unpacked
Run Code Online (Sandbox Code Playgroud)
复制丢失的测试二进制文件
sudo cp coreutils_unpacked/usr/bin/test /usr/bin/test
Run Code Online (Sandbox Code Playgroud)
添加可执行权限
sudo chmod +x /usr/bin/test
Run Code Online (Sandbox Code Playgroud)
或者,如果您想下载完整的 .iso 文件
从官方网站下载iso文件
创建一个临时目录来挂载 iso 文件
mkdir ubuntu_iso_tmp
Run Code Online (Sandbox Code Playgroud)
将 iso 文件挂载到新创建的目录中
sudo mount -o loop ~/Downloads/Ubuntu_whatever.iso ubuntu_iso_tmp
Run Code Online (Sandbox Code Playgroud)
复制丢失的测试二进制文件
sudo cp ubuntu_iso_tmp/usr/bin/test /usr/bin/test
Run Code Online (Sandbox Code Playgroud)
Gil*_*il' 16
对于 的具体情况/usr/bin/test,还有另一个程序/usr/bin/[是相同的,只是它需要一个额外的最后一个参数,即]。GNU coreutils 是这些程序在 Ubuntu 和其他非嵌入式 Linux 系统下的实现,它将这两个程序作为单独的可执行文件提供,因此即使其中一个程序损坏或丢失,您也可以使用另一个程序。/usr/bin/test使用以下内容创建:
#!/bin/sh
/usr/bin/\[ "$@" \]
Run Code Online (Sandbox Code Playgroud)
使其可执行 ( chmod a+rx /usr/bin/test),您就拥有了/usr/bin/test.
然后运行apt reinstall coreutils即可恢复正常/usr/bin/test。
coc*_*mac 13
我建议从实时 USB 中获取已删除的文件并将其放回去。就是这样。
apt输出表明了这一点),Ubuntu 21.10 ISO 应该适合您。从此处下载带有 ISO 标签的桌面映像。ls,您应该会看到一个以.AppImage. 做chmod +x balenaEtcher-1.7.3-x64.AppImage。./balenaEtcher-1.7.3-x64.AppImage。/mnt/mainfs示例,但您应该使用真实位置。sudo cp /usr/bin/test /mnt/mainfs/usr/bin/test. 替换/mnt/mainfs为您安装主系统的位置。apt应该可以再次工作。您可以重新安装主包并让触发器完成这项工作。在这种情况coreutils下,它提供的任何工具都将由 的脚本重新安装coreutils。不仅test。
wget http://ph.archive.ubuntu.com/ubuntu/pool/main/c/coreutils/coreutils_8.32-4ubuntu2_amd64.deb
Run Code Online (Sandbox Code Playgroud)
sudo dpkg --unpack coreutils_8.32-4ubuntu2_amd64.deb
Run Code Online (Sandbox Code Playgroud)
sudo dpkg --configure coreutils
Run Code Online (Sandbox Code Playgroud)
完毕。
| 归档时间: |
|
| 查看次数: |
10397 次 |
| 最近记录: |