What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
On a standard Ubuntu installation, run hostnamectl to see the current hostname and sudo hostnamectl set-hostname web-node-1 to change it. Replace web-node-1 with a simple name of your choice, then run hostnamectl again to verify the result. The change normally persists on a conventional local system; cloud instances may use provisioning or network settings that replace it.
Find your current Ubuntu hostname
Open a terminal and run:
hostnamectl
The status output includes the machine’s hostname information. To print the hostname currently active in the kernel, run:
hostname
Systemd also lets you inspect individual hostname types:
hostnamectl --staticdisplays the configured static hostname.hostnamectl --transientdisplays the runtime hostname, which can be supplied by network configuration.hostnamectl --prettydisplays the presentation-friendly name, if one is set.
On Ubuntu 24.04, these commands are documented in the Ubuntu Noble hostnamectl manual. Ubuntu 22.04 uses the same broad hostname-type model; if your installation is unusually old or customized, check its installed hostnamectl manual for supported options.
#1 Best Overall
Change the hostname
- Choose a DNS-style name: lowercase letters, digits, and hyphens, without spaces. For example,
web-node-1. - Set it from a terminal, substituting your chosen name:
sudo hostnamectl set-hostname web-node-1 - Verify the setting:
hostnamectlYou can also run
hostnameto check the active kernel hostname.
With no type-selection option, hostnamectl set-hostname sets the pretty, static, and transient hostname values. The system simplifies the value for static and transient hostnames if it contains characters those types do not allow. To change only one type, use its corresponding option, such as sudo hostnamectl --static set-hostname web-node-1. See the Ubuntu Noble hostnamectl manual for the command’s documented options.
Rank #2
Choose a compatible hostname
A static or transient hostname is intended to be a DNS-style name. Keep it to lowercase ASCII letters, digits, and hyphens; avoid spaces and other special characters. The documented maximum hostname length is 64 characters. For the /etc/hostname file, the Ubuntu manual recommends using a single label, such as web-node-1, rather than a dotted name.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesSystemd distinguishes three hostname types:
- Static: the configured system name, normally stored in
/etc/hostnameand applied at boot. - Transient: the runtime name, which may be provided by network configuration such as DHCP. It is used when no static hostname is configured.
- Pretty: a human-friendly display name that can use UTF-8 characters and spaces.
These distinctions and the 64-character limit are documented in the Ubuntu Noble hostname manual and the Ubuntu Noble /etc/hostname manual.
Rank #3
Will the hostname change persist after reboot?
On a conventional local Ubuntu installation, hostnamectl set-hostname changes the static hostname kept in /etc/hostname; systemd applies that configured name at boot. A transient name can instead come from network configuration when no static hostname is set. The Ubuntu /etc/hostname manual documents the file and its role in local hostname configuration.
If the name returns to its previous value after a reboot, check whether cloud-init or another provider-specific setup manages the machine’s hostname. In cloud-init, the preserve_hostname setting controls whether cloud-init changes the hostname. Cloud-init can also rewrite /etc/hosts at boot; if that is enabled, persistent local edits belong in the configured hosts template. See the cloud-init 22.4.2 module reference.
Rank #4
There is a specific Google Cloud exception: on Google Compute Engine images using Ubuntu 24.04 LTS or later, /etc/hostname is not present by default and cloud-init’s create_hostname_file key is false. In that setup, changing the name with the hostname command can be temporary because Google DHCP may overwrite it. Follow the provider or cloud-init configuration for that instance, then verify the name after reboot. This behavior is specific to the documented GCE images, not all Ubuntu 24.04 systems. See Ubuntu’s GCE hostname guidance.
Recommended Free Tools
Hostname, FQDN, and /etc/hosts are different settings
The machine hostname is not necessarily a fully qualified domain name (FQDN). An FQDN is derived through name resolution and depends on the system’s name-service configuration. A local entry in /etc/hosts maps an IP address to a canonical hostname and may include aliases; it does not, by itself, make a short hostname into a universally resolvable domain name.
Best Value
If local services or scripts refer to the old hostname, review their existing /etc/hosts entries before editing them. The Ubuntu Jammy hosts manual explains the file’s mapping format. The Ubuntu hostname and FQDN manual also cautions that resolver-derived FQDN results may be unsuitable on systems with multiple interfaces or mobile network environments.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

