Q. I have CentOS 7.0 virtual private server, but the default hostname still localhost.localdomain. How do i change the hostname to my prefer hostname or FQDN ?
[root@localhost ~]# hostname localhost.localdomain
A. There are four(4) method to change the hostname on CentOS 7.0/RHEL 7.0.
1. Login to your VPS as a root.
2. Type hostname followed by the new hostname.
As example :
[root@localhost ~]# hostname mynewhostname.local [root@localhost ~]# hostname mynewhostname.local
Note : But the following changes will be lost after reboot.
1. Login to your VPS as a root.
2. Use hostnamectl set-hostname command to change the current hostname :
As example :
[root@localhost ~]# hostnamectl set-hostname ns1.e-coupondeals.com
3. Restart the systemd-hostnamed daemon to reflect the changes permanently :
[root@localhost ~]# systemctl restart systemd-hostnamed
4. Check the new hostname :
[root@localhost ~]# hostnamectl status Static hostname: ns1.e-coupondeals.com Icon name: computer-vm Chassis: vm Machine ID: 72863e389b584a4dab36fae7f3bffda2 Boot ID: 1cf2f4b5478649549916c0a5bd5d2414 Virtualization: xen Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.15.4-x86_64-linode45 Architecture: x86_64
1. Login to your VPS as a root.
2. Modify /etc/hostname using your favourite text editor replace localhost.localdomain to your most prefered hostname or FQDN:
[root@ns1 ~]# vi /etc/hostname
Edit to the following as example :
ns1.e-coupondeals.com
3. Try to login again by opening another putty session :
[root@ns1 ~]# hostname ns1.e-coupondeals.com
1. Login to your VPS as a root.
2. Type nmtui in the terminal:
[root@ns1 ~]# nmtui
3. Text user interface will appear :
4. Using the arrow keys select Set system hostname and use tab to select OK.
5. Confirmation message will appear, Press OK to complete.