CentOS Change Hostname

One of the most common changes to CentOS servers is modifying the hostname. Hostnames are human-readable nicknames that correspond to the address of a device connected to a network. Some software such as CPanel require a valid Fully Qualified Domain Name or FQDN for the hostname to be used during their Licensing verification system.

1. Sysconfig/Network: Open the /etc/sysconfig/network file with your favourite text editor. Modify the HOSTNAME= value to match your FQDN host name:

# sudo nano /etc/sysconfig/network

2. Hosts File: Change the host that is associated to your main IP address for your server, this is for internal networking, found at /etc/hosts:

3. Hostname Command: The 'hostname' command will let you change the hostname on the server that the command line remembers, but it will not actively update all programs that are running under the old hostname.

# hostname yourserver.yourdomain.co.nz
# hostname

4. Restart Networking: All necessary changes that needed to be made have been made, you need to restart networking on your server to make sure that changes will be persistent on reboot:

# /etc/init.d/network restart

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

cPanel Server Time

Setting the server timezone in cPanel is very easy. Having the correct server time helps when...

Dovecot Is Not Running on cPanel

Quite a common error with Dovecot running on Xen hypervisors, especially for clients who use...

mySQL Errcode: 24

The mySQL error: Errcode: 24 is an indication that the number of files that mySQL is allowed to...

Swap Disk Size

What is swap? Swap space is the area on a hard disk which is part of the Virtual Memory of your...

Log Slow MySQL Queries

MySQL can often use excessive CPU cores or time out unexpectedly. The slow-query-log can assist...