Responsive Ads Here

Saturday, 14 April 2018

How to Set Hostname on CentOS VPS


Introduction

Hostname is the program that is used to either set or display the current host, domain or node name of the system. These names are used by many of the networking programs to identifiy the machine.

In this article, we assume that you have login as the root user. Let's begin!

Step One:

Change your hostname to a different name of your choosing by typing hostname yourhostname then press enter. For example:
hostname server01

Step Two:

Open the /etc/hosts file with your favorite text editor. For example:
nano /etc/hosts
Then change the first line and replace your old hostname with the new one. Save the file and exit the editor.

Step Three:

We'll edit /etc/sysconfig/network file that also contains your hostname by run the following command:
nano /etc/sysconfig/network

Change HOSTNAME=yourhostname to your desired hostname. For example:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server01
GATEWAY=192.168.1.1
Save the file and exit the editor.

Note: Don't change anything other than what I mention it.

Step Four:

Check your hostname by run the following command:
hostname
The new hostname will be displayed in your ssh terminal.

That's it. You have Set a new Hostname on your VPS server.

No comments:

Post a Comment