Answered by the Webhosting Experts

How to Change the Hostname of a Server

In Linux, a hostname is a unique name that identifies a device on a network, and is used to identify the device in various network protocols and systems. A hostname can be set during the installation of the operating system or later using various commands.

There are several reasons why you might need to change the hostname in Linux. One common reason is to avoid duplicate names on the same network. If you have more than one computer on your home network and want them all running Linux, you’re going to want to change the default hostnames to avoid problems.

Changing a Server’s Hostname

To change the hostname of your system, follow the steps below. In this example, we are changing the hostname of our server to “NewHostname”.

sudo hostnamectl set-hostname NewHostname

Now, you can confirm that the change has occurred by checking the new hostname using either of the following commands:

hostname OR hostnamectl

Screenshot showing the results of the sudo hostnamectl set-hostname NewHostname command.

An Important Note for cPanel Users

If you’ve changed your hostname in a cPanel environment, it is recommended that you run the following command to update your cPanel license information on the new hostname. This will allow you to avoid a potential invalid cPanel license error.

/usr/local/cpanel/cpkeyclt

Screenshot showing the results of the /usr/local/cpanel/cpkeyclt
command.

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here at: support@hivelocity.net. We are also available to you through our phone and live chat system 24/7/365.