If you getting an error “Sudo unable to resolve host” while executing sudo command in Ubuntu, then here’s how you can fix the issue.
Below is the snapshot of the error:
ubuntu@test$ sudo su - sudo: unable to resolve host (test)
Check if /etc/hostname contains the correct hostname of your machine.
$ vi /etc/hostname
Check if /etc/hosts file contains the below line with hostname appended at the end.
$ vim /etc/hosts
127.0.0.0 localhost.localdomain localhost hostname_of_machine
If the above two files contain the correct hostname of your machine, then sudo will resolve properly.