我该如何重新安装 APT 工具?

我该如何重新安装 APT 工具?

我想重新安装 APT 工具,所以我卸载了它,然后我意识到如果我删除目录可能会更好/etc/apt。有什么方法可以解决我的错误吗?

我的 Ubuntu 版本是 18.04.2 LTS,输出ls /etc/apt

root@user-OptiPlex-755:~# ls /etc/apt 
ls: cannot access '/etc/apt': No such file or directory

更新:我已经重新安装apt,但是这是我的输出:

root@user-OptiPlex-755:~# sudo apt install --reinstall apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package update-manager is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
ubuntu-release-upgrader-core update-manager-core

Package update-notifier-common is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

Package update-notifier is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
update-notifier-common

Package apt-utils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
apt

Package ubuntu-release-upgrader-gtk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'apt-utils' has no installation candidate
E: Unable to locate package ubuntu-minimal
E: Package 'ubuntu-release-upgrader-gtk' has no installation candidate
E: Unable to locate package ubuntu-desktop
E: Package 'update-manager' has no installation candidate
E: Package 'update-notifier' has no installation candidate
E: Package 'update-notifier-common' has no installation candidate`

答案1

如果使用 删除 APT sudo apt remove apt,则标准安装中的以下软件包会受到影响(至少在 bionic (18.04) 中):

apt apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common

要重新安装 APT:

  • 下载APT的.deb文件。

    wget http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.8_amd64.deb
    
  • 使用 dpkg 安装。

    sudo dpkg -i apt_1.6.8_amd64.deb
    
  • 由于您/etc/apt也删除了,因此下载来自 GitHub 的 bionic zip 文件,提取它并使用以下命令复制 apt 文件夹:

    sudo cp -r ~/Downloads/Bionic/apt /etc/
    

    并运行更新:

    sudo apt update
    
  • 再次安装已删除的软件包。

    sudo apt install apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common
    

另外,永远不要试图弄乱系统文件/软件包,如 Python、APT 等,它们对于操作系统非常重要。它们可能会导致您的系统崩溃。如果您需要重新安装软件包,请运行:

sudo apt install --reinstall <package>

答案2

更新:我旁边确实有一台 Ubuntu 服务器,所以我将它/etc/apt与这台 Ubuntu 合并,问题就解决了。感谢您的帮助,我很确定我的第二个问题的核心是我缺少文件/etc/apt/sources.list。一旦我复制了这些文件,我就可以安装已删除的软件包。再次感谢您的帮助!

相关内容