In this CentOS 5.5 tutorial we will be showing you how to change the hostname. 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.
To find the machine’s fully qualifier domain name (FQDN) see for yourself how the machine identifies itself:
# uname -n
centos01.how2centos.com
# dnsdomainname
how2centos.com
There are a couple of ways to change the hostname. Edit the /etc/sysconfig/network and change the hostname
# vi /etc/sysconfig/network
1 2 3 | NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=centos01.how2centos.com |
or run System Config
# system-config-network
Select Edit DNS configuration
âââââââ⤠Select Action âââââââ
â
â Edit a device params
â Edit DNS configuration
â
â
â
â âââââââââââââ ââââââââ
â â Save&Quit â â Quit
â âââââââââââââ ââââââââ
â
â
âââââââââââââââââââââââââââââââââââââ⤠DNS configuration âââââââ
â
â
â Hostname centos01.how2ce
â Primary DSN 10.0.0.10______
â Secondary DNS _______________
â Tertiary DNS _______________
â Search how2centos.com_
â
â ââââââ ââââââââââ
â â Ok â â Cancel â
â ââââââ ââââââââââ
â
â
ââââââââââââââââââââââââââââââââââ
Edit the hostname and select OK and then Save&Quit
TIP: If you would like to strip off the domain name portion, which is stored elsewhere anyway.
# sed -i.bak 's/\.[a-z].*//g' /etc/sysconfig/network
# cat /etc/sysconfig/network
1 2 3 | NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=centos01 |
# uname -n
centos01
# dnsdomainname
how2centos.com
Dont forget to change the hostname in your hosts file
# vi /etc/hosts
1 2 3 4 | # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 centos01.how2centos.com centos01 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 |
However we’re not finished. The machine wont normally see the updated hostname until about it reboots, but we can force it to update.
# source /etc/sysconfig/network
# hostname $HOSTNAME
Video: CentOS: Change that hostname

7 Comments » 
