Why I got 'unable to resolve host' when I do 'sudo'? [duplicate]
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.
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.