1

Yes, Might be duplicate of following links Tried both links solutions but didn't worked for me.

  1. Error message when I run sudo: unable to resolve host (none)

  2. sudo: unable to resolve host ubuntu-server

Following is my /etc/hosts output:

127.0.0.1 kaushal
120.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost.com


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

Following is my /etc/hostname output:

127.0.0.1 kaushal
120.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost.com

Every time when I write command sudo apt-get update I get following error message.

sudo: unable to resolve host 127.0.0.1kaushal

Also in my terminal I get kaushal@127:~$ as following screenshot. enter image description here

It was not like that before.

All this started happening after I change my username from

All Setting >  Details > Device name

Any suggestion what's wrong with my machine?? How can I resolve this problem. Let me know if you want more details.

2 Answers2

4

I solved the problem by going to
All Setting > Details > Device Name
changed the device name to kaushal
Just make sure that your /etc/hostname file has only your machine name.For my case it was kaushal

1

I will answer your question specifically
In your /etc/hosts for localhost change 127.0.0.1 kaushal to
127.0.1.1 localhost localhost.localdomain kaushal