5 views
by

Check the current hostname

[root@localhost ~]# hostname
localhost
[root@localhost ~]#

Issue hostnamectl command in CentOS 7, in this example we are changing the hostname from localhost to askdevops

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

One more change, make this change in /etc/hosts file as well

[root@localhost ~]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1   askdevops

Save the /etc/hosts file

Welcome to Ask DevOps!
You can find quick one line answers to popular DevOps, Amazon AWS, Microsoft Azure, Google cloud services, tools & basic to advanced Linux questions!
DevOps Tools list
.. 
...