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

Every time I boot, CentOS 6.0 Server hostname disappears. I have to re-issue hostname command to reset it.

Please help!

share|improve this question
up vote 8 down vote accepted

you need to set your host name properly in /etc/sysconfig/network

share|improve this answer
Works! Wonder how the network file got updated automatically?! I remember putting the correct fqdn while installation!!! Thanx a lot! – Anshuman Mar 22 '12 at 14:12
not a problem glad to help. For some reason it does this on some of my servers too on a fresh install, dont have the time to look into why.. i just make it practice to check this after the install completes before i do the rest of the server configuration, a 2 second check :) Could be something to do with SELinux, but wouldnt like to say for sure :) – LloydOliver Mar 22 '12 at 14:23
@JDI Can I do this via some kind of one-liner? – Nickolai Leschov Apr 2 '14 at 23:39

Add a line


to the /etc/sysconfig/network file to set the hostname to your.hostname.tld

share|improve this answer
I think you typically do not want the FQDN here, instead you want the short hostname. The domain should be present in /etc/resolv.conf and, optionally, in a DOMAIN= variable in the same file. – Kyle Smith Mar 22 '12 at 13:34
@KyleSmith: No, you would normally put the fqdn here for both CentOS 6 and CentOS 5. No mention of a DOMAIN setting in either document either. – Iain Mar 22 '12 at 14:08
Works! I put the whole fqdn in the network file. Will try what you are suggesting too! For now, issue resolved. I'm new to Linux and these small things frustrate a lot :-P Thanx!!!! – Anshuman Mar 22 '12 at 14:14
@Iain, can you point me to the documentation you're looking at. Maybe I'm doing it wrong :) – Kyle Smith Mar 22 '12 at 15:27
@KyleSmith: I did, the links are CentOS 6 and Centos 5 above – Iain Mar 22 '12 at 15:57

Your Answer


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

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