Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

We have centos machine. We have tried both the /etc/hosts and also /etc/sysconfig/network. Edited both files and service network restart. Yet the hostname is showing as localhost.localdomain. How to resolve on this? Googling almost all talking about the same method too.

share|improve this question
up vote 2 down vote accepted

From this answer : How to change the hostname of a linux machine using terminal?

Have you tried running the command :

hostname new_hostname

where "new_hostname" would be value you are trying to set ?

share|improve this answer
it works but will it be permanent there? How about the other steps with regards to /etc/sysconfig/network and /etc/hosts? Must I still edit those ? – biz14 Jul 27 '13 at 16:49
Yes, you should edit those files too. The two files are for the "permanent" changes, the "hostname" command is for "on the fly" change. – Louis Carrese Jul 28 '13 at 9:50
ok let me test I am not too sure about the /etc/hosts how where and what to change exactly can you please verify as some said just put beside the hostname is this correct? – biz14 Jul 28 '13 at 15:12

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.