首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Debian命令行无法解析主机。

Debian命令行无法解析主机。
EN

Stack Overflow用户
提问于 2014-04-27 15:49:11
回答 2查看 6.5K关注 0票数 0

我的远程命令行无法解决本地主机名的问题。它不显示为user@localhostuser@ip或任何变体,而是显示为user@(none)

代码语言:javascript
复制
Using username "rogue".
rogue@<my-ip>'s password:
Linux (none) 3.13.7-x86_64-linode38 #1 SMP Tue Mar 25 12:59:48 EDT 2014 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sun Apr 27 15:34:56 2014 from ---
rogue@(none):~$

任何程序命令都会导致此警告消息:

代码语言:javascript
复制
rogue@(none):~$ sudo service nginx start
sudo: unable to resolve host (none)
[sudo] password for rogue:

看着我的主机和主机名文件,我没有看到任何异常的东西:

/etc/主机名

代码语言:javascript
复制
127.0.0.1 localhost
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/主机

代码语言:javascript
复制
127.0.0.1       localhost
127.0.1.1       debian

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我的网络配置可能有什么问题?如果可能的话,我希望它是user@my.domain,但我需要localhost仍然正确地路由到127.0.0.1

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-04-27 15:55:50

你的/etc/hostname是非常错误的。它应该是FQDN的纯文本,如example.comlocalhost,而不是/etc/hosts的类似副本。

您可能希望使用命令hostname查看和设置主机名,man it

票数 2
EN

Stack Overflow用户

发布于 2022-09-24 08:27:41

这些命令呢?

代码语言:javascript
复制
hostname here.yourhost.name
sudo sed -i "s|localhost|localhost $(hostname)|g" /etc/hosts

在/etc/host中在其他本地主机名旁边添加主机名

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23325451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档