CentOS how to change hostname?

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!

Tags:

9 Responses to “CentOS how to change hostname?”

  1. Umarzuki says:

    # system-config-network

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

  2. tijn says:

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

  3. TheBigK says:

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

  4. Pierluigi Vernetto says:

    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?

  5. Pierluigi Vernetto says:

    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

  6. nick says:

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

  7. Bob says:

    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

  8. claudio says:

    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.

  9. claudio says:

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

Leave a Reply