This way of Setting Hostname and FQDN on Ubuntu and Centos


Setting Hostname and FQDN on Ubuntu and Centos 5, 6, 7 32 and 64 bit. The most basic thing that has to be controlled by the user’s server (VPS) anywhere in this world, good Linux users Ubuntu, Centos Linux or other operating system users is knowing how to create, edit, and change the setting of the hostname and Fully Qualified Domain Name (FQDN). Indeed it is not compulsory, but both are two things that are difficult to pass when you manage your VPS for various purposes, such as when making mail server, ftp server, control panel server and so on.

Setting Centos Server
Understanding Hostname and FQDN:

As the name suggests, hostname (hostname) is a unique name that is used as a nickname for a computer in a network (intranet or internet). According to wikipedia, the Hostname is the host name or computer name. This specific naming, to a specific computer in a network. Due to its unique, then in one network can’t be 2 or more hostnames are the same. If it happens the same naming, then the system will tell you that there has been duplication of names. But if the computer is not connected to the network each other give the same computer name is not a problem. Hostname (hostname) consists only of the following things:

The letters a to z.
The digits 0 to 9.
Hyphen (-)

Hostname is part of the Fully Qualified Domain Name (FQDN) or the full name of the Domain. The fully Qualified Domain Name is the complete hostname consisting of a hostname (domain level 3), domain names (domain level 2) and the type of ownership (domain level 1). The example on the FQDN, details of which are as follows:

mail as the hostname (domain level 3).
sshagan as a domain name (domain-level 2).
com as a type of ownership, i.e. commercial (domain level 1).

The FQDN is also often referred to as an Absolute Domain Name.

Setting Hostname and FQDN

Here is a way of setting the Hostname and Fully Qualified Domain Name or FQDN in Ubuntu and Centos:

Check the Hostname and FQDN

Check hostnameBerikan the following command to know the hostname on the server Ubuntu or Centos:


The picture shows that the VPS is the hostname of the server.

FQDNBerikan check command below to know the FQDN of the server in Ubuntu or Centos:


Setting The Hostname:
You can create a hostname (hostname) anything to your liking. However, there are several host names commonly used by the owner of the server as the name of the mail, webmail, pbx, web, web1, web2, web3, server, server1, server2, server3, and so on. To be able to set (settings) hostnames server (VPS) Centos or Ubuntu Linux, you can use an editor like vim, vi, nano or other editors. In this article I will use the vim editor vim editor, reason being is already available by default and requires no installation process first. If you want to use the nano editor, please install the nano editor in advance at your server.

Command for setting the hostname in Ubuntu:

sudo vim/etc/hostname

Command for setting the hostname in Centos:

sudo vim/etc/sysconfig/network

Press button i to do the editing. Use the direction arrows right, left, up, down on the keyboard to move the cursor and please type the host name that you want. Press the ESC key on your keyboard, if you’ve finished the edit or replace hostname with hostname that you want. Save and exit the file settings by typing: wq (enter).

Restart service hostname with the command:

sudo service hostname restart

Please check your server hostname with the command:


Cara Setting The FQDN (Fully Qualified Domain Name)
Please remember that the hostname is part of the FQDN. If you want to set the FQDN, then you have to adjust with the hostname that you create. In addition you should also adjust the also with the domain name you have.
Read the article:

How to get free domain for up to one year
How to list domains at Namecheap

To set the FQDN, please enter the following command:

sudo vim/etc/hosts

Press button i on the keyboard as usual to be able to edit the FQDN of your server. Edit the FQDN settings became as follows: localhost.localdomain localhost URhostname.yourdomain.tld hostname
YourIP URhostname.yourdomain.tld hostname

Replace hostname with the name of your host, URyourdomain.tld with your domain name and your server with IP yourip. For example: localhost.localdomain localhost server server

Press the ESC key after you finish doing the editing, and then type: wq and enter to save the settings and exit from the/etc/hosts file.
To assure you are the Fully Qualified Domain Name (FQDN) is turning or not, please re-enter the command:


If it hasn’t changed, try to restart your server in advance using the command:


So how to create hostname and Fully Qualified Domain Name (FQDN) of the server on Ubuntu and Centos. If you want to be able to use your server’s FQDN meremote you made above, the next step please connect your server IP to the domain for the FQDN settings or your DNS configuration. In addition, please make sure that you’re connecting to your server IP to the domain by making the pointer (PTR) record.



This site uses Akismet to reduce spam. Learn how your comment data is processed.