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

At work, I have a Linux server which I would like to change the name from "testmain" to "test1". I have contacted the IT guys to change the DNS to associate the new name to its static IP and it works. What is left now is to change the host name on the server. I have tried the 'hostname' command and it seems to work, but a reboot will reset the hostname back. I appreciate any pointers. Here is the output of uname -a:

Linux testmain 2.6.9-67.0.7.ELsmp #1 SMP Wed Feb 27 04:47:23 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

The server is running Red Hat Enterprise Linux. Thank you.

share|improve this question
up vote 4 down vote accepted

You can specify it in /etc/sysconfig/network:

share|improve this answer
Thank you Chris. It works. – Hai Vu Oct 14 '09 at 17:39

In addition to updating the /etc/sysconfig/network or /etc/hostname as suggested by others you will probably want to check and update the file /etc/hosts. On many installations an entry will be added to that file associating your computer name with a loopback address or the the IP address you used when you installed the computer.

share|improve this answer
Thanks Zoredache, I updated /etc/hosts as well. These are great tips. – Hai Vu Oct 14 '09 at 17:40
and to be extra sure, run a grep -r youroldhostname over /etc, maybe you find a few more places (like mail server configuration)... – mihi Oct 14 '09 at 18:18
mihi: You are right. I found one in /etc/passwd so I changed that as well. +1 – Hai Vu Oct 17 '09 at 16:08

If you change the hostname in the file /etc/hostname, the change will persist beyond reboots.

share|improve this answer
Thanks. I looked and my system does not have that file--must be how it was setup. – Hai Vu Oct 14 '09 at 17:37
That location is where you would usually look on a debian-based system. – Zoredache Oct 14 '09 at 23:15
ayaz & Zoredache: Thank you both. You are right. I looked at my Ubuntu machine at home and found /etc/hostname there. +1 – Hai Vu Oct 17 '09 at 16:06

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.