Why Does Changing My Hostname Cause `sudo` to Hang on Ubuntu?
Asked by
CuriousCat42
I recently ran into a curious issue on my Ubuntu system where using `sudo` would hang for several minutes after my VPN's kill-switch kicked in. I discovered that `sudo` tries to resolve the hostname to the system's Fully Qualified Domain Name (FQDN) by default on Ubuntu, since it's compiled with the `--with-fqdn` flag. At some point, I altered my system hostname, but `etc/hosts` didn't get updated automatically, leading to a mismatch with the new hostname. When my VPN's kill-switch blocked DNS requests, the hostname resolution failed, resulting in `sudo` hanging while it waited for a timeout.
I'm looking for thoughts on this situation:
- Should tools like `hostnamectl` or the Settings app automatically update `etc/hosts` when the hostname changes, or at least notify the user?
- Is it wise for `sudo` to have FQDN resolution enabled by default, as it is on Ubuntu? It seems like it introduces an avoidable point of failure for such an essential tool. For instance, Fedora doesn't activate this option by default, and Debian is thinking about removing it as well.
Answers
Changing a hostname on an established server isnโt usually a good idea. It can lead to all sorts of complications like this. Typically, it's better to rebuild the system than to just change the hostname.
Reply to this answer
It sounds like a classic DNS problem! Iโve had similar experiences, especially when logging in via SSH with faulty DNS. Always a headache.
Reply to this answer
Exactly! Plus, not every system is a server; some are just workstations. It might not be as critical to change those.
Reply to this answer
Thatโs quite the issue! If you didnโt update `etc/hostname`, what exactly did you change? Were you modifying the static entries in `etc/hosts` or messing with DNS settings?
Reply to this answer
I agree with rebuilding, but I get that itโs not feasible for everyone. Usually, changing a DNS entry is all thatโs needed rather than a hostname change.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions