33

Whenever I do 'sudo' I get an error saying 'sudo: unable to resolve host HP-Pavilion'. I recently change my hostname to "HP-Pavilion". I wonder if I screw up something.

$ sudo mkdir SourceCodePro
sudo: unable to resolve host HP-Pavilion
[sudo] password for mike:

Thank you for your help.

  • The question linked as duplicate actually isn't an exact duplicate. There the user has no host at all (none is displayed instead of hostname), while here it is not the case. The questions are related but not exactly the same, as is also apparent from the titles. – texnic Jun 11 '17 at 19:41
65

You changed the host name to HP-Pavilion, but it's not in the file /etc/hosts. So try to add the name to /etc/hosts file and also don't forget to add it to /etc/hostname file .

Your /etc/hosts and /etc/hostname files will look like this,

$ cat /etc/hostname
HP-Pavilion
$ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   HP-Pavilion

Restart your pc to make changes work.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.