Debian 系统更新 “Name or service not known”解决方法
最近新买了一台小鸡,主机面板中安装了 Debian 11 minimal 。在连接后更新系统出现了下面的报错:
sudo: unable to resolve host xxx: Name or service not known
如果你不知道自己的主机名可以使用一下命令查看:
cat /etc/hostname
本文默认主机名称为 “xxx”。
将返回值复制,打开hosts文件:
sudo nano /etc/hosts
本机默认 hosts 文件为:
127.0.0.1 localhost
127.0.1.1 debian11
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
在文件中将 127.0.0.1 localhost
后添加本机主机名,使用空格间断。
修改如下:
127.0.0.1 localhost xxx
127.0.1.1 debian11
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
问题解决。