终端找不到命令,并且下载(wget)不起作用

终端找不到命令,并且下载(wget)不起作用

我认为我的 Ubuntu 安装已损坏,因为现在它无法识别某些终端命令,例如 ufw/glances(已安装)。结果如下。

-bash: ufw: command not found

sudo apt update --fix-missing无法正常工作,因为它会产生以下结果。

Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://lk.archive.ubuntu.com/ubuntu focal InRelease                                                       
  Temporary failure resolving 'lk.archive.ubuntu.com'
Err:3 http://gb.archive.ubuntu.com/ubuntu bionic InRelease                                                      
  Temporary failure resolving 'gb.archive.ubuntu.com'
Err:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease      
  Temporary failure resolving 'ppa.launchpad.net'
Err:5 http://lk.archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'lk.archive.ubuntu.com'
Err:6 http://ppa.launchpad.net/gluster/glusterfs-3.12/ubuntu focal InRelease
  Temporary failure resolving 'ppa.launchpad.net'
Err:7 http://lk.archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'lk.archive.ubuntu.com'
Err:8 http://ppa.launchpad.net/gluster/glusterfs-6/ubuntu focal InRelease
  Temporary failure resolving 'ppa.launchpad.net'
Reading package lists... Done       
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://lk.archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'lk.archive.ubuntu.com'
W: Failed to fetch http://lk.archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'lk.archive.ubuntu.com'
W: Failed to fetch http://lk.archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'lk.archive.ubuntu.com'W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://gb.archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'gb.archive.ubuntu.com'
W: Failed to fetch http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/dists/focal/InRelease  Temporary failure resolving 'ppa.launchpad.net'
W: Failed to fetch http://ppa.launchpad.net/gluster/glusterfs-3.12/ubuntu/dists/focal/InRelease  Temporary failure resolving 'ppa.launchpad.net'
W: Failed to fetch http://ppa.launchpad.net/gluster/glusterfs-6/ubuntu/dists/focal/InRelease  Temporary failure resolving 'ppa.launchpad.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.

在 ubuntu 20.2 中,我尝试将 Python 版本从 3.8 降级到 3.5 以运行特定程序时发生了这种情况。我有点晚才看到不推荐这些程序的评论,此时已经太晚了。

几点说明:我的路径如下(and it contains bin, /usr/bin and /usr/local/bin)

/home/chameera/.local/bin:/opt/lib/mpich/bin:/opt/lib/netcdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • 使用 wget,无法下载任何文件,但可以通过 ssh 进入和退出机器,以及传输文件
  • ping 8.8.8.8 有响应,但没有响应www.google.com
  • sudo dpkg --configure -asudo rm /var/lib/apt/lists/lock清除、sudo rm /var/lib/dpkg/locksudo rm /var/lib/dpkg/lock-frontend中的锁定文件后不生成任何输出sudo rm /var/lib/apt/lists/* -vf

我还没有重启机器,因为它是一台远程机器,而且我有点担心重启,担心我可能会再次失去对它的访问权限,直到我物理恢复机器。如果你们能在这方面帮助我,我将不胜感激。

提前谢谢您!

答案1

您需要撤消对 python 的降级,我不确定您是如何做到的。

修复之后,我建议使用蟒蛇管理其他 Python 版本(切勿触碰系统 Python!)或在另一个目录树中单独安装 CPython,例如/opt/python/<version>。使用后一种选项,您可以使用环境模块或者模式轻松交换软件版本,类似于 python 虚拟环境或 conda 环境。

相关内容