A machine's hostname identifies it to applications and network services. In openSUSE and SLES, a rename must update both the running and persistent names, then check saved configuration and local name resolution.
On systemd-based SUSE systems, hostnamectl updates the running hostname through systemd-hostnamed and stores the persistent value in /etc/hostname. A valid static hostname takes precedence over a transient name received from network configuration, so a reboot is not needed to apply the rename.
A short DNS-safe name suits most machines, while managed networks may require a fully qualified domain name. Renaming the system does not update DNS records, monitoring targets, certificates, or other machines' saved references to the old name; those dependencies need a coordinated change to avoid failed lookups or certificate checks. An existing host-specific entry in /etc/hosts also needs to match the new name.
Steps to change the hostname in openSUSE and SLES:
- Check the current hostname.
$ hostname linux-ui1m
- Set the new hostname with hostnamectl.
$ sudo hostnamectl set-hostname server1.example.com
- Update any old hostname in /etc/hosts using a text editor.
$ sudo vi /etc/hosts
192.168.1.20 server1.example.com server1
The IP address and all other lines stay unchanged. No edit is needed when the old name is not in the file.
- Confirm that the system uses the new hostname.
$ hostname server1.example.com
An open terminal can keep showing the old name in its prompt until a new terminal or login session starts.
If the name changes back later, check which management layer owns the hostname. On openSUSE Leap 15.6 and SLES 15 systems with YaST, also check Change Hostname via DHCP under Network Settings → Hostname/DNS.