A Fedora system has a hostname that helps it identify and distinguish itself on a network. Sometimes this name appears as part of a fully qualified domain name (FQDN). A FQDN includes not just the system’s name, but the Internet domain, separated by periods (.).

Hostname conventions

To be valid, a hostname may only contain letters a-z, numerals 0-9, and dashes (-). An example is office-01. The FQDN for that machine might be office-01.example.com, where example.com is the domain.

Each Fedora system also has a special reserved name, localhost, which it sometimes uses to refer to itself. This may sound like overkill, but it’s useful. The localhost lets the system easily access services that it is providing itself. You may also see this reserved name as a FQDN in the form localhost.localdomain.

Setting the hostname

To set the name of a single, modern Fedora system such as a home computer that isn’t part of a network, use the hostnamectl command:

hostnamectl set-hostname new-name

Getting fancy

The hostnamectl utility distinguishes between three different kinds of names:

  1. The static name used by default at system bootup
  2. The transient name assigned by network configuration
  3. The pretty name which may be more descriptive, like “Mary’s living room laptop”

The pretty name isn’t limited to just the valid characters for static or transient name.

The command above sets all names to the same value. To set only one of them, use one or more of the options –static, –transient, or –pretty.

The static name is stored in the /etc/hostname file for later reference. You can also check the current status of all names with this command:

hostnamectl status

The utility tracks other information, such as icons that may be used to represent the system in graphical interfaces. For more information, check out this Freedesktop.org page.

Using Cockpit

You can also use Cockpit to control the hostname settings in your system, or a remote system. If you’re not familiar with Cockpit, check out this overview we published earlier. Cockpit allows you to set the system name with a point and click operation.

First, from the dashboard select System. Notice this dashboard refers to localhost, which is your local system itself.

Cockpit dashboard view - System

Select the Host Name to modify the current settings:

Cockpit - changing the system names

Image courtesy Travis Wise – originally posted to Flickr as Hello My Name Is.