Networknet.nl Blog

Stay Connected

CentOS how to change hostname?

with 9 comments

Today I needed to change the hostname of my virtual guest machine running CentOS.

  • Login with putty.exe
  • Goto /etc/sysconfig/
  • Type vi network
  • Press i on the keyboard and change the HOSTNAME to your preferred servername
  • Press ESC on the keybord
  • Save the configuration by :wq!
  • Reboot

2007-11-21_154313.png

That’s all!

Written by Ivan Versluis

November 21st, 2007 at 4:41 pm

Posted in CentOS

Tagged with

9 Responses to 'CentOS how to change hostname?'

Subscribe to comments with RSS or TrackBack to 'CentOS how to change hostname?'.

  1. # system-config-network

    and change hostname under DNS tab, logout then login again would do also.

    Umarzuki

    11 Sep 08 at 1:43 am

  2. You don’t need to reboot, just logout and login.

    tijn

    4 Feb 09 at 4:24 pm

  3. echo “newhostname” > /proc/sys/kernel/hostname and you dont need to reboot. Reboot is just for new kernel ;D

    TheBigK

    26 Mar 09 at 7:24 pm

  4. I have changed hostname, on a CentOS 5.3 on VMWare player, but after the change the startup becomes extremely slow, even opening Terminal takes 30s…. I have made sure the entry in the DNS tab in system-config-network is correct, and restarted…. if I restore the previous hostname value (bagvapp) the respose times become normal again…
    anybody experiencing the same problem?

    Pierluigi Vernetto

    11 Jun 09 at 12:18 pm

  5. ah ok I forgot to add the new hostname in the 127.0.0.1 entry in the hosts file…
    the procedure is described here:
    http://javamonamour.blogspot.com/2009/06/centos-change-hostname-and-ips.html

    Pierluigi Vernetto

    11 Jun 09 at 12:26 pm

  6. /etc/init.d/network restart will do after change the hostname. :)

    nick

    3 Dec 09 at 5:47 am

  7. And you can also type as root in console: “setup” and then go to “Network Configuration” and edit the DNS config.

    And you may want to check your /etc/hosts

    Bob

    21 Dec 09 at 12:36 pm

  8. Thanks guys, but the TheBigK’s solution don’t persist before restart.
    The Umarzuki and Bob solutions are OK.
    Muchas gracias, Thank to all.
    Sorry for my bad english.

    claudio

    17 Feb 10 at 5:40 pm

  9. don’t persist “after” restart… is the correct form…
    Sorry again.
    Good luck.

    claudio

    17 Feb 10 at 5:43 pm

Leave a Reply