How to Change hostname of the server using SSH?

Linux Dedicated Server allows you to host mulitple websites under your web hosting space. Linux Dedicated Server comes with full root access where you will be having control to make any changes at any time. A hostname is a Fully Qualified Domain Name (FQDN) and used to identify your server also it is the label (the name) assigned to a device (a host) on a network and is used to distinguish one device from another on a specific network or over the internet.

Step 1: Login to your Server

Step 2: Use the hostname utility

Change your hostname to a different name of your choosing. For example:

hostname server01

Step 3: Edit /etc/hosts
Open the /etc/hosts file with your favorite text editor. For example:

nano /etc/hosts

Change the first line and replace your old hostname with the new one. Save the file and exit the editor.

Step 4: Edit /etc/sysconfig/network

This file also contains your hostname. Open the /etc/sysconfig/network file with your favorite text editor.

Change HOSTNAME=vultr to your desired hostname. For example: HOSTNAME=server01.

Step 5: Check your hostname
Run the following command to check your new hostname:

hostname

The new hostname will be displayed in your ssh terminal