Unable to Resolve Host
If every sudo command prints:
sudo: unable to resolve host my-server: Name or service not knownThe server’s hostname is missing from /etc/hosts, usually after you change the hostname. Commands still run, but each one waits for the failed lookup first.
Fixing it
Section titled “Fixing it”Check the current hostname:
hostnameOpen the hosts file:
sudo nano /etc/hostsAdd a line with the hostname, or change the old hostname on the existing 127.0.1.1 line:
127.0.1.1 my-serverSave with Ctrl+X, then Y and Enter. The warning stops on the next sudo command.