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.

3 Answers 3

4

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

NETWORKING=yes
HOSTNAME=myawesomebox
0
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.

3
  • Thanks Zoredache, I updated /etc/hosts as well. These are great tips.
    – Hai Vu
    Oct 14, 2009 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, 2009 at 18:18
  • mihi: You are right. I found one in /etc/passwd so I changed that as well. +1
    – Hai Vu
    Oct 17, 2009 at 16:08
3

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

3
  • Thanks. I looked and my system does not have that file--must be how it was setup.
    – Hai Vu
    Oct 14, 2009 at 17:37
  • 2
    That location is where you would usually look on a debian-based system.
    – Zoredache
    Oct 14, 2009 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, 2009 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .