在 PATH 中找不到“rm”或不可执行

Dan*_*erg 4 linux debian

好吧,我犯了一个错误。我尝试从 coreutils:i386 升级到 coreutils:arm64,但出了问题。现在我已经没有很多程序了,包括 rm、touch、chmod 和 mv。

所以,我尝试运行apt-get install coreutils

root@srv028:/tmp# apt-get install coreutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  coreutils
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2,727 kB of archives.
After this operation, 14.6 MB of additional disk space will be used.
dpkg: warning: 'rm' not found in PATH or not executable
dpkg: error: 1 expected program not found in PATH or not executable
Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
E: Sub-process /usr/bin/dpkg returned an error code (2)
Run Code Online (Sandbox Code Playgroud)

我确实有备份,但这意味着半天的工作会丢失。所以我的问题是,这可以恢复吗?如果是这样,怎么办?

小智 5

好吧,首先感谢https://unix.stackexchange.com/questions/115743/i-deleted-bin-rm-how-do-i-recover-it的批准

sudo touch /bin/rm
sudo chmod +x /bin/rm
apt-get download coreutils
sudo dpkg --unpack coreutils*
Run Code Online (Sandbox Code Playgroud)

您在 rm 应该所在的位置创建一个虚拟文件,并添加执行权限。下载 coreutils 应用程序(不需要 sudo),然后安装文件。dpkg 将读取 coreutils 包并进行安装。