Error message "sudo: unable to resolve host (none)"
Two things to check (assuming your machine is called my-machine
, you can change this as appropriate):
That the
/etc/hostname
file contains just the name of the machine.-
That
/etc/hosts
has an entry forlocalhost
. It should have something like:127.0.0.1 localhost.localdomain localhost 127.0.1.1 my-machine
If either of these files aren't correct (since you can't sudo), you may have to reboot the machine into recovery mode and make the modifications, then reboot to your usual environment.
Edit /etc/hosts
and append your new hostname to the 127.0.0.1 line (or create a new line if you prefer that).
Mine looks like:
127.0.0.1 localhost localhost.localdomain penguin
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Replace penguin
in the above example by your new hostname as stated in the /etc/hostname
file.
Add your hostname to /etc/hosts
like so:
echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts