Your Guide to How To Change Hostname In Linux
What You Get:
Free Guide
Free, helpful information about Computers & Operating Systems and related How To Change Hostname In Linux topics.
Helpful Information
Get clear and easy-to-understand details about How To Change Hostname In Linux topics and resources.
Personalized Offers
Answer a few optional questions to receive offers or information related to Computers & Operating Systems. The survey is optional and not required to access your free guide.
How to Change the Hostname in Linux: A Complete Guide
Your Linux machine's hostname is its identity on a network — the name other devices and services use to recognize it. Whether you're setting up a server, reorganizing a home lab, or just inherited a machine with a generic name like localhost, knowing how to change the hostname cleanly is a fundamental Linux skill.
The process is straightforward, but the right method depends on your Linux distribution, whether the change needs to survive a reboot, and how deeply the hostname is woven into your system's configuration.
What Is a Hostname in Linux?
A hostname is a human-readable label assigned to a machine. Linux actually recognizes three types:
| Hostname Type | Description | Example |
|---|---|---|
| Static | The traditional hostname stored in system files | webserver-01 |
| Pretty | A free-form display name (can include spaces/capitals) | John's Web Server |
| Transient | A temporary name assigned by the kernel or DHCP | dhcp-192-168-1-10 |
For most purposes — especially on servers — you're working with the static hostname. That's the one that persists across reboots and appears in your shell prompt.
Method 1: Using hostnamectl (Modern Systemd Systems) 🖥️
On any Linux distribution running systemd — which includes Ubuntu 16.04+, Debian 8+, CentOS 7+, Fedora, and most modern distros — hostnamectl is the cleanest and most reliable tool.
Check your current hostname: