How to Change Hostname in OCI Compute Environment on Oracle Linux Permanently

--

I changed the hostname in oci compute instance, When I rebooted the instance, the instance hostname changed to the default hostname.

So I needed to change the hostname permanently in oci instance.

I followed the below steps.

1. In the file /etc/oci-hostname.conf change the value of PRESERVE_HOSTINFO to 2.
/etc/oci-hostname.conf
PRESERVE_HOSTINFO=2

This change will be persistent across reboots.

2.Edit /etc/sysconfig/network

change the parameter value for “hostname”

# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=<new_hostname> ← — — — — change here

3.Update the /etc/hostname file with the below command.
hostnamectl set-hostname <new_hostname>

--

--