Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 4 down vote accepted

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

NETWORKING=yes
HOSTNAME=myawesomebox
share|improve this answer
    
Thank you Chris. It works. –  Hai Vu Oct 14 '09 at 17:39
add comment

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
2  
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
add comment

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
2  
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
add comment

Your Answer

 
discard

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.