Tuesday, 12 April 2016

How to add or change hostname in RHEL7/CentOS 7



By default, while installation the server is started with the default host name as localhost.localdomain. Host name for a system is like an identity for that system to makes system management and also we can use host name to access the system over the LAN.


This article describes how to change server host name in CentOS7/RHEL7. Replace host name as you desire.

[root@localhost ~]# hostnamectl set-hostname linuxcnf

You need to modify file /etc/hostname and make changes as per below snaps for hostname:

[root@localhost ~]# vi /etc/hostname
linuxcnf
[root@localhost ~]#

You need to modify file /etc/hosts and make changes as per below snaps for host entry:

[root@localhost ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.43.107 linuxcnf

Now you have to re-login for immediate effect.

[root@linuxcnf ~]#

It’s done!!!

No comments:

Post a Comment