在使用Debian的官方源安装操作系统后,部分情况下可能无法使用apt安装任何软件。
使用命令
apt update
没有错误,但是也没有更新任何内容。此时,安装任何软件都提示:
package has no installation candidate
这是因为apt的源设置的不对,默认安装的情况下,源中包含的软件库非常有限。
这时候,如果打开apt的source文件,就可以看到:
root@ouc:~# vim /etc/apt/sources.list # deb cdrom:[Debian GNU/Linux 11.3.0 _Bullseye_ - Official amd64 NETINST 20220326-11:22]/ bullseye main #deb cdrom:[Debian GNU/Linux 11.3.0 _Bullseye_ - Official amd64 NETINST 20220326-11:22]/ bullseye main deb http://security.debian.org/debian-security bullseye-security main deb-src http://security.debian.org/debian-security bullseye-security main # bullseye-updates, to get updates before a point release is made; # see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports # This system was installed using small removable media # (e.g. netinst, live or single CD). The matching "deb cdrom" # entries were disabled at the end of the installation process. # For information about how to configure apt package sources, # see the sources.list(5) manual.~
可以看到这里面的源很少,不完整。可以设置为阿里云的源。
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb https://mirrors.aliyun.com/debian-security/ bullseye-security main deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free
如果不想输入,可以直接使用在线的一些资源进行覆盖。
cd /etc/apt/ mv sources.list sources.list.old wget https://dataset.yangyq.net/sources.list
完成之后,再进行更新和安装就可以了。