sudo: unable to resolve host hostname

If using sudo gives the error message “unable to resolve host hostname” then one solution is to add the hostname in /etc/hosts

127.0.0.1	hostname.domain.com	hostname localhost