Centos

Change Hostname on CentOS 7

Centos-Logo
Written by admin

Here will show you how to change hostname on your CentOS 7 server.

For the beginners who don’t have basic knowledge of Linux  & how to use shell .

know how to execute the command and update the hostname .

Login the server through SSH with root account, if not you may need to add ‘sudo’ to the commands to get root privileges. If you are ready open up your terminal and follow through this tutorial, and  in few minutes you will have changed your hostname on a CentOS 7 server.

Change Hostname on CentOS 7

Step 1.:
First  check the current hostname by running “hostnamectl status” on the shell of my server:

hostnamectl status

The output on my system is:

[root@idroot ~]# hostnamectl status
Static hostname: server.example.com
Icon name: computer-vm
Chassis: vm
Machine ID: e894ee16491e1e611e693r6we99e6e9
Boot ID: 767fh984nf48y4n48t4t84tn4t84tnh8t49
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64

Step 2:
Change and Set Hostname.

To change the hostname type the command:

hostnamectl set-hostname server.serversupportpro.com

Check the host name again (Close the session and open new session using console):

[root@idroot ~]# hostnamectl status
Static hostname: server.serversupportpro.com
Icon name: computer-vm
Chassis: vm
Machine ID: e894ee16491e1e611e693r6we99e6e9
Boot ID: 767fh984nf48y4n48t4t84tn4t84tnh8t49
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64

In each of these configurations, you’ll need to be sure your hostname conforms to the standards for FQDNs (Fully Qualified Domain Names). The ASCII letters a – z, the digits 0 – 9, and the hyphen (‘-‘) are the only characters acceptable (the first character, however, cannot be a hyphen). You may also find it necessary (or useful) to include the domain name as well, in which case you would then also use periods (dots) to separate the hostname and the domain name (and top-level domain).

You have successfully changed the hostname .

Thanks for visiting and using this tutorial to change the hostname in centos 7

About the author

admin

Leave a Comment