This question already has an answer here:

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.

marked as duplicate by Eric Carvalho, Ravan, Pilot6, AzkerM, David Foerster Dec 29 '15 at 11:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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

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
$ cat /etc/hosts   localhost   HP-Pavilion

Restart your pc to make changes work.

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