I am trying to find what my VM's hostname is. When I do cat /etc/hosts I get: localhost

Is localhost the hostname? The DNS domain name isn't written where do I find that? When I write hostname -d I get hostname: Name or service not known

2 Answers 2


Localhost is a local hostname used to communicate on loopback. It's like

Your DNS hostname is trickier to find. First, you don't have one per se. You have to configure one in your dns server, then you'll be able to ping your hostname.

The Command hostname, without the "-d" will print your VM's hostname. At least the one you configured. For me, without any configuration it is "localhost.localdomain". You should have the same.

What are you trying to achieve with your hostname?


No, localhost is (most likely) not your hostname. To find out your hostname use the command


and use

hostname -f

to display the fully qualified domain name (FQDN). How the hostname and the DNS domain are set depends on the distribution, see this answer for more on this.

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.