How To Change Hostname on CentOS 7

r00t July 7, 2016

Change Hostname on CentOS 7

In this tutorial we will show you how to change hostname on your CentOS 7 server. For those of you who didn’t know, Hostname is a label that is assigned to a device connected to a computer network and that is used to identify the device in various forms of electronic communication. This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The tutorial is quite simple and assumes you are running in the 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 less than 10 minutes you will have changed your hostname on a CentOS 7 server.

Change Hostname on CentOS 7

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

The output on my system is:

Step 2. Change and Set Hostname.

To change the hostname type the command:

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

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).

Congratulation’s! You have successfully change hostname. Thanks for using this tutorial how to change and set hostname on your CentOS 7 system. For additional help or useful information, we recommend you to check the official CentOS web site.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!

Save

Share on Google+0Share on Facebook0Tweet about this on TwitterShare on Tumblr0Share on StumbleUpon1Share on Reddit1Pin on Pinterest2
The Tags:

Leave a Comment