2

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.

Hai Vu
  • 199
  • 2
  • 9

3 Answers3

5

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.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • 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
4

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

NETWORKING=yes
HOSTNAME=myawesomebox
Chris Brentano
  • 306
  • 1
  • 4
3

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

ayaz
  • 483
  • 3
  • 10