Error message when I run sudo: unable to resolve host

I have this issue on AWS on some servers. Whenever I run sudo the terminal is stuck doing seemingly nothing, until it finally spits out this error message. My terminal looks like this:

[email protected](none):~$ sudo true
sudo: unable to resolve host (none)

What can I do to solve it?

Please post the contents of /etc/hostname and /etc/hosts

make sure your hostname same with hosts. e.g. the hostname is ubuntu-pc and hosts is ubuntu-pcmust be same.

wo things to check (assuming your machine is called my-machine, you can change this as appropriate):

  1. That the /etc/hostname file contains just the name of the machine.
  2. That /etc/hosts has an entry for localhost. It should have something like:
     127.0.0.1    localhost.localdomain localhost
     127.0.1.1    my-machine

If either of these files aren‘t correct (since you can‘t sudo), you may have to reboot the machine into recovery mode and make the modifications, then reboot to your usual environment.


时间: 2024-08-09 23:56:21

Error message when I run sudo: unable to resolve host的相关文章

sudo: unable to resolve host xxx解决办法

问题: [email protected]:~# sudo lsb_release -a sudo: unable to resolve host wiki No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.1 LTS Release: 14.04 Codename: trusty 可见我的主机名为wiki(机器hostname),每次执行sudo 就会出现这个警告sudo: unable

一组相关联的问题:“sudo: unable to resolve host ###: Connection timed out”、软件启动速度超慢、IPv6无法使用

近日陆续发现计算机出现几个问题,最终发现这些问题实际上是由同一个原因导致的 问题1:无法使用IPv6 问题2:无论是启动Emacs GUI还是在命令行中执行emacs -nw指令,打开Emacs的时间很长,且提示"sudo: unable to resolve host ###: Connection timed out" 问题3:打开/etc/hosts时提示文件正在被使用无法显示文件内容 解决方法:在/etc/hosts中,增加一行"127.0.1.1 ###"

Ubuntu 报错 sudo: unable to resolve host

使用SSH连接阿里云的轻量应用型服务器 Ubuntu实例执行命令 sudo su root时,提示: 基本使用sudo开头的命令都会提示此信息,看着比较不爽. 虽然sudo 还是可以正常执行, 但是警告讯息每次都出来,而这只是机器在反解上的问题, 所以就直接从/etc/hosts 设定, 让abc(hostname) 可以解回127.0.0.1 的IP 即可. 解决方案 需要修改/etc/hosts文件: sudo vi /etc/hosts 在 127.0.0.1 localhost 下添加一

sudo: unable to resolve host 枝桠

Ubuntu环境, 主机名字叫枝桠(机器的hostname), 每次执行sudo 就出现这个警告讯息: 虽然sudo 还是可以正常执行, 所以就直接从/etc/hosts 设定, 让枝桠(hostname) 可以解回127.0.0.1 的IP 即可. 在127.0.0.1 localhost 后面加上主机名称(hostname) 即可: 127.0.0.1 localhost 枝桠

sudo 出现unable to resolve host 解决方法

inux 环境, 假设这台机器名字叫dev(机器的hostname), 每次执行sudo 就出现这个警告讯息:sudo: unable to resolve host dev虽然sudo 还是可以正常执行, 但是警告讯息每次出来还是有点烦人, 而这只是机器在反解上的问题, 所以就直接从/etc/hosts 设定, 让dev(hostname) 可以解回127.0.0.1 的IP 即可. /etc/hosts 原始内容 127.0.0.1       localhost # The followi

Ubuntu sudo 出现unable to resolve host 解决方法

Ubuntu环境, 假设这台机器名字叫abc(机器的hostname), 每次执行sudo 就出现这个警告讯息:sudo: unable to resolve host abc虽然sudo 还是可以正常执行, 所以就直接从/etc/hosts 设定, 让abc(hostname) 可以解回127.0.0.1 的IP 即可. 在127.0.0.1 localhost 后面加上主机名称(hostname) 即可: 127.0.0.1 localhost abc

sudo 出现unable to resolve host hostname 解决方法

Linux 环境,我的电脑叫枝桠(机器的hostname), 每次执行sudo 就出现这个警告讯息: sudo: unable to resolve host 枝桠 直接修改 /etc/hosts 的内容,在 127.0.0.1 localhost 后面加上自己机器的hostname,我的是枝桠,加上后就是 127.0.0.1 localhost 枝桠

Error prompt:“wget: unable to resolve host address”---Solution

//Situation System prompts that:"wget: unable to resolve host address". //Analysis Unable to resolve host address means the problem of DNS(Domain Name System).  //Solution To fix the problem, the configuration file "resolv.conf" should

Aandroid Error之 新导入工程报Unable to resolve target 'android-18'和R cannot be resolved

有段时间没有写安卓了,今天导入以前的项目,结果看到控制台打印出了这样一句:Unable to resolve target 'android-18', 解决方法: 项目->属性->Android->Project Build Target 选择android 4.4Target,保存.结果原来报的一大堆错误消失了,只剩一个错误,R cannot be resolved然后点project->clean,如图.结果错误就消失了. Aandroid Error之 新导入工程报Unabl