How To Change Hostname on CentOS 7

To get started, you need to log into your server. To do this, use the following connection guides:

Use the hostname utility

You need to change the hostname to another name of your choice. For instance:

hostname server_1

Edit /etc/hosts

Open the /etc/hosts file in your acceptable text editor:

nano /etc/hosts

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

Edit /etc/sysconfig/network

This file also contains your hostname. Open the /etc/sysconfig/network file in your favorite text editor. Change HOSTNAME=vps.hostry.com to your desired hostname. For example: HOSTNAME = server_1.

Check your Hostname

For this check, enter the following command:

hostname

The new hostname will be displayed in your ssh terminal.

Was this article helpful?

Related Articles

Leave A Comment?