Change the hostname of a Linux machine that’s already joined to Active Directory

  1. First, leave the Active Directory domain:
sudo realm leave gcs.cloud
  1. Change the hostname using hostnamectl:
sudo hostnamectl set-hostname new-hostname.gcs.cloud
  1. Rejoin the Active Directory domain:
realm join gcs.cloud

See also:

Deploy a Amazon Linux 2023