Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server where I am facing this strange issue that hostname command does not print anything.

[root@localhost ~]#/bin/hostname
[root@localhost ~]#

[root@localhost ~]# cat /etc/hosts localhost localhost.localdomain
::1 localhost localhost.localdomain localhost localhost.localdomain

[root@localhost ~]# cat /etc/sysconfig/network
[root@(localhost) ~]#
share|improve this question
Can you try removing the package called net-tool and re-install it. Hope that should work. – Pratap Jan 2 '13 at 10:39
thanks let me give it a shot – user151598 Jan 2 '13 at 10:44
What's the value of $HOSTNAME in your shell? And what's the value of $? immediately after running hostname? I'm tempted to think that your hostname is currently set to the empty string (although I'm not quite sure how you would achieve that). – Ladadadada Jan 2 '13 at 10:45
Is this a CentOS 5 system ? – Iain Jan 2 '13 at 10:47
Did you try re-setting your hostname using hostname localhost ? – Heis Spiter Jan 2 '13 at 10:54

You have multiple entries for localhost.localdomain in /etc/hosts - this is not a good idea. Continuing to use localhost.localdomain as a hostname is also giving you a headache.

Please set a real hostname using hostname, then set it in the /etc/hosts for the non-localhost IP, and in /etc/sysconfig/network.

Then try hostname, hostname -a, and hostname -f to see if all three work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.