How to Set a Pretty Hostname in Ubuntu Using hostnamectl

Every Ubuntu installation is assigned a system hostname during initial operating system installation. While standard network hostnames (known as the static hostname) must adhere strictly to Internet RFC specifications—meaning they are limited to lowercase alphanumeric characters, numbers, and hyphens without spaces (such as web-prod-01 or ubuntu-desktop)—modern Linux environments running systemd also support a separate Pretty Hostname.

A pretty hostname is an unrestricted, human-friendly UTF-8 string that can include capital letters, spaces, punctuation, and descriptive department or owner names (such as Development Staging Server (London DC) or Sarah's ThinkPad X1). Pretty hostnames are displayed across desktop system settings, local network discovery menus, Bluetooth pairings, and remote management consoles. In this guide, you will learn how to inspect, set, and clear pretty hostnames in Ubuntu using hostnamectl.

The Three Types of Hostnames in Ubuntu

Understanding how systemd categorises hostnames ensures you configure your machine correctly:

  • Static Hostname: The traditional Unix hostname stored in /etc/hostname. Used for network resolution and shell prompts (e.g. server-node1).
  • Transient Hostname: A temporary hostname assigned by network DHCP servers or mDNS during runtime. Defaults to the static hostname.
  • Pretty Hostname: A high-level, human-readable UTF-8 identification string stored in /etc/machine-info for user interface presentation.

Step 1: Check Your Current Hostname Status

To inspect all currently assigned hostnames on your Ubuntu machine, open your terminal and run hostnamectl without arguments:

hostnamectl status

The output will display your operating system details, kernel version, architecture, and current Static hostname. If a Pretty hostname has not been set yet, only the Static hostname line will be visible.

Step 2: Assigning a Pretty Hostname

To assign a descriptive, human-readable name containing spaces and capitalisation, use the --pretty flag followed by your desired text inside quotes:

sudo hostnamectl set-hostname --pretty "Engineering Staging Server (Node 4)"

Because pretty hostnames support full UTF-8 formatting, you can include accented characters, punctuation, and parentheses. The command executes instantaneously without requiring a system reboot.

Step 3: Verifying the Configuration

To verify that your new pretty hostname has been registered by systemd, re-run:

hostnamectl status

You will now see the new entry at the top of the output:

   Static hostname: engineering-staging
   Pretty hostname: Engineering Staging Server (Node 4)
         Icon name: computer-vm
           Chassis: vm

You can also inspect the underlying configuration file directly:

cat /etc/machine-info

The file will confirm: PRETTY_HOSTNAME="Engineering Staging Server (Node 4)".

How to Clear or Remove a Pretty Hostname

If you no longer wish to display a custom pretty hostname and prefer system dialogs to revert back to your standard static hostname, reset it with an empty string:

sudo hostnamectl set-hostname --pretty ""

The pretty hostname entry will be removed immediately from /etc/machine-info, leaving your network static hostname intact.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.