Changing Hostname in an OCI Compute Instance (Oracle Linux)

Changing Hostname in an OCI Compute Instance (Oracle Linux)

Steps to Change Hostname

  1. Modify the OCI Hostname Configuration File
    Edit the /etc/oci-hostname.conf file and set PRESERVE_HOSTINFO to 2. This ensures that the hostname change persists across reboots.

    sudo nano /etc/oci-hostname.conf
    

    Update the file with the following line:

    PRESERVE_HOSTINFO=2
    

    Save and exit the file.

  2. Update the Hostname
    Use the hostnamectl command to set the new hostname:

    sudo hostnamectl set-hostname lmlab
    

After completing these steps, the hostname of the OCI compute instance will be updated and persist across reboots.

Leave a Reply

Your email address will not be published. Required fields are marked *