A persistent hostname identifies a Linux server and remains set after a restart. On systems using systemd, hostnamectl can set and display this name.
Check the existing name
Run:
hostnamectl status
hostnameBefore changing a hosting server’s name, check dependencies such as mail configuration, certificates and monitoring. For cPanel or Plesk, use the control panel’s supported hostname procedure.
Set a persistent hostname
On a standalone systemd server, replace the example with the intended name:
sudo hostnamectl set-hostname server1.example.comCheck the result:
hostnamectl status
cat /etc/hostnameA plain hostname command can change the running name temporarily, but it does not reliably update persistent configuration.
Check related configuration
Update relevant DNS records and any local hosts-file entry that still uses the old name. A hostname change does not create DNS records automatically.
Cloud-init or a hosting platform may reset the hostname from provider configuration. If the name reverts, review that platform’s settings rather than repeatedly editing /etc/hostname.