CentOS 5 Change Hostname

In this CentOS tutorial we will be showing you how to find and change the hostname of your system.

The assumption is that you are running as root and have a basic understanding of the software required but if you follow this tutorial you should be able to complete the task successfully.

Let us begin by finding the CentOS systems fully qualified domain name (FQDN) by seeing how it identifies itself.

Print the network node hostname

Show the systems DNS domain name

There are a couple of ways to change the hostname.

Edit /etc/sysconfig/network

or run System Config

Select Edit DNS configuration

Edit the hostname and select OK and then Save&Quit

Dont forget to change the hostname in your hosts file

However we’re not finished. The machine wont normally see the updated hostname until about it reboots, but we can force it to update.

  • Gunn

    Good god. Thank you! After trying numerous websites, your tutorial and video finally solved my name change issue. Much appreciated

  • Anonymous


  • Har

    Thank you so much for your tutorial, it was the missing piece much needed for my cloned virtual box guest machines

  • http://www.mod-page-speed.com Joe

    My Friend,
    I tip my hat to you.. It solved my problem!

  • Lokasgr

    hi!! i have a problem with terminal. When i open it as root the command name is -bash-3.2#

    CentOS release 5.6 (Final)
    Linux ks209884 #1 SMP Tue Apr 12 17:19:35 UTC 2011 x86

    _64 x86_64 x86_64 GNU/Linux

    server    :
    ip        :
    hostname  : ks209884


    when i use command to chance path dont shows it changes.
    it returns


    can you help me to solve it??

    Thank you a lot!

  • Anonymous

    At the command prompt paste this and hit enter, does anything happen ?

    # PS1=”[[e[36;1m]u[e[31;1m]@[e[32;1m]h[e[0m]:[e[36;1m]w[e[0m]]# “

  • kris

    Thanks a lot