Knowledgebase: VPS Tutorials
Change Hostname of Linux, CentOS, Ubuntu and Debian
Posted by RAJU K, Last modified by RAJU K on 25 January 2016 02:14 AM

Changing the Hostname

You’ll need to set your system’s hostname and fully qualified domain name (FQDN). Your hostname should be something unique. Note that the system’s hostname has no relationship to websites or email services hosted on it, aside from providing a name for the system itself. Your hostname should not be “www” or anything too generic.

Hostname's examples, "server1", "wwwbox2", or "".


CentOS 7 / Debian 8 / Fedora version 18 and above / Ubuntu 15.04

Replace hostname with one of your choice.

hostnamectl set-hostname hostname


Debian 7 / Slackware / Ubuntu 14.04

Replace hostname with one of your choice.


echo "hostname" > /etc/hostname 

hostname -F /etc/hostname


Check if the file /etc/default/dhcpcd exists.

ls /etc/default

If so, edit it and comment out the SET_HOSTNAME directive:



CentOS 6 / Fedora version 17 and below

Replace hostname with one of your choice.

1) echo "HOSTNAME=hostname" >> /etc/sysconfig/network
2) hostname "hostname"


Update /etc/hosts

Next, edit your /etc/hosts file to resemble the following example, replacing hostname with your chosen hostname, with your system’s domain name, and with your system’s IP address. As with the hostname, the domain name part of your FQDN does not necessarily need to have any relationship to websites or other services hosted on the server (although it may if you wish). As an example, you might host “” on your server, but the system’s FQDN might be “”

/etc/hosts localhost.localdomain localhost hostname

If you have IPv6 enabled on your Linode, you will also want to add an entry for your IPv6 address, as shown in this example:

/etc/hosts localhost.localdomain localhost hostname 
0:0:0:0:0:ffff:43e3:e637 hostname


Now your VPS is ready with new hostname.


Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).