How to change Compute Instance hostname

This guide covers changing the hostname for instances running the following operating systems: Ubuntu 18.04-22.04, AlmaLinux 8, Rocky Linux 8, and CentOS 7-8.

Prerequisite

  • An instance running one of the following operating systems: Ubuntu 18.04-22.04, AlmaLinux 8, Rocky Linux 8, or CentOS 7-8.

Instruction

1. Access the instance you want to modify

SSH to the Linux Instance.

2. Use the following command to change the hostname

Replace with your desired new hostname.

$ sudo hostnamectl set-hostname <newNameHere>

3. To verify the change was successful, use the command below. Alternatively, you can log out and log back into the instance to see the updated hostname.

$ hostnamectl
Change the instance's hostname and verify the change.
Log out of the instance and then log back in.

Last updated

Was this helpful?