cat /etc/hosts returns two results:  Localhost  [mycomputersname].[city].[state].[domain].net  (brackets for anonymity)

When I run hostname, it returns [mycomputersname] without the .*.* etc etc

Whenever I run sudo, it tells me it can't resolve [mycomputersname]

If I manually change the hosts table to remove the .*.* etc, then it works fine. Until it changes it back at some point (reboot?) and it starts all over again. What is going on here and what can I do to fix it? Thanks!

Apologies if this is a dumb question. I'm very new to Linux.


Try this /etc/hosts line:  [mycomputersname].[city].[state].[domain].net mycomputersname

You can specify aliases this way.

hostname uses the /etc/hostname file to get its output (among other sources). You could set the fully-qualified domain name as the hostname as well:

hostnamectl set-hostname [mycomputersname].[city].[state].[domain].net
  • Also, be sure to add "localhost" to the same line. Much software tries to find an IP address for "localhost". Having two lines beginning with confuses the software (which one does it pick? How does it know?). – waltinator Sep 29 '14 at 19:47
  • @waltinator That's why this line use, and is localhost. – muru Sep 29 '14 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.