This article is intended for Linux server administrators who need to change the hostname of their server. If your server is hosted with and managed by Maxer, please contact our support team and we can do this for you. Do not attempt these steps if you are unsure.

Your server hostname should always be a fully qualified domain name (FQDN), for example:

server1.example.com


For cPanel servers

On cPanel servers, the recommended method is to change the hostname in WHM:

  1. Log in to WHM as root.

  2. Navigate to:
    WHM » Home » Networking Setup » Change Hostname

  3. Enter the new hostname (for example server1.example.com) and click Change.

After changing the hostname, you must resync your cPanel license to ensure it matches the new hostname. Run this command via SSH as root:

/usr/local/cpanel/cpkeyclt

For non-cPanel servers with a control panel

If you are using a different control panel (e.g. Plesk, DirectAdmin, Webmin), refer to the official documentation for that panel. Each control panel has its own method for changing the system hostname.


For servers without a control panel

On a standard Linux server, you can change the hostname directly from the command line.

Temporary change (until reboot):

hostnamectl set-hostname server1.example.com

Permanent change (across reboots):

  • On systemd-based distributions (CentOS 7+, AlmaLinux, Rocky Linux, Ubuntu 16.04+):

     
    hostnamectl set-hostname server1.example.com
  • On older distributions (without hostnamectl):

    1. Edit /etc/hostname and replace the old hostname with the new one.

    2. Edit /etc/hosts and update the hostname entry.

    3. Apply the change:

      hostname server1.example.com

✅ Your server hostname is now updated.

Updated by SP on 02/10/2025

Was this answer helpful? 256 Users Found This Useful (267 Votes)