Visit Counter

Tuesday, January 12, 2021

How to change host name in Oracle Linux 7.8

 

Use hostnamectl which is a command-line client to systemd-hostnamed service

=========================================================

[root@localhost sysconfig]# hostnamectl status

   Static hostname: localhost.localdomain

         Icon name: computer-vm

           Chassis: vm

        Machine ID: 12289ebafa0e47dea5171eee463b29aa

           Boot ID: e370b31606ac4f41a6df3b96498ac107

    Virtualization: kvm

  Operating System: Oracle Linux Server 7.8

       CPE OS Name: cpe:/o:oracle:linux:7:8:server

            Kernel: Linux 3.10.0-1127.el7.x86_64

      Architecture: x86-64


Set hostname:

============

[root@localhost sysconfig]# hostnamectl set-hostname oraerptest19c.com

[root@localhost sysconfig]# 


Re-Login terminal session:

===================

[root@localhost sysconfig]# hostnamectl status

   Static hostname: oraerptest19c.com

         Icon name: computer-vm

           Chassis: vm

        Machine ID: 12289ebafa0e47dea5171eee463b29aa

           Boot ID: e370b31606ac4f41a6df3b96498ac107

    Virtualization: kvm

  Operating System: Oracle Linux Server 7.8

       CPE OS Name: cpe:/o:oracle:linux:7:8:server

            Kernel: Linux 3.10.0-1127.el7.x86_64

      Architecture: x86-64


[root@localhost sysconfig]# nmcli general hostname

oraerptest19c.com

[root@localhost sysconfig]# hostname

oraerptest19c.com

[root@localhost sysconfig]# nmcli general hostname oraerptest19c.com

[root@localhost sysconfig]# systemctl restart systemd-hostnamed

[root@localhost sysconfig]# 

[root@localhost sysconfig]# 


[root@localhost sysconfig]# hostname

oraerptest19c.com


[root@localhost sysconfig]# 

[root@localhost sysconfig]# cat /etc/hostname

oraerptest19c.com