Linux

How To Set The System Hostname In CentOS

In this article you will learn how to setup your system hostname.

By default the system hostname is called localhost. The hostname must be less than 64 characters and can contain only alpanumerical characters and dashes.

Step 01: Let’s first check our current hostname:
Command: hostnamectl 

Output:

Step 02: and now let’s rename the current hostname to Hurricane for example by setting the static and pretty name.

Commands:

hostnamectl –static set-hostname “Hurricane”

hostnamectl –pretty set-hostname “Hurricane”

 

Step 03: The below command will update the  file /etc/hostname from where the system reads its hostname.

cat /etc/hostname

Nota Bene: You need to restart the system for changes to take effect.

 

That’s it!