How to set the hostname on Fedora

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, where 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 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.

For System Administrators


  1. lec

    Excellent technical note! I wish there were more like this in Fedora Magazine. Suggestions for other articles: (1) an explanation about services, with comments on which ones can be disabled; (2) clarifications about UEFI, as for example, whether it should be disabled or not in BIOS, with comments on the consequent advantages and disadvantages, issues regarding suspend, etc; (3) tools for setting up and controlling sound (pulseaudio, alsa).

    • Sebastiaan Franken

      About your number 2: You cannot disable UEFI, since that’s the successor to the old BIOS. You’re getting UEFI and Secure Boot mixed up I think.

      Secure boot is the technology which refuses to boot code (in this case the OS) if it 1) isn’t signed or 2) it’s key isn’t known to the UEFI. As far as I know Fedora is signed by Red Hat and thus boots on a UEFI machine with Secure Boot turned on. In the past booting with secure boot (and Microsoft Windows) was a hassle, I agree.

  2. Yauhen

    You can also set it just with

    hostname new-name
  3. pablo

    “that isn’t part of a network”… what’s the way to set the fully qualified hostname when the system is part of a network?

    To be honest when I saw the article listed in fedoramagazine I was expecting to read the gory detais, where are the hostname and domain stored? How the “current” hostname can be different, and how to sync them, when you edit the files by hand (or why you should avoid this)?

    Thanks for the article anyway 🙂 I had never heard about hostnamectl or cockpit.

    • Sebastiaan Franken

      Hostnamectl does the same thing as “hostname”, with one execption. It also updates /etc/hostname , which hasn’t changed since the “hostname” days, so that’s nothing new.

      AFAIK you shouldn’t update the hostname “in memory” only, since that can have some weird effects with network enabled applications. Always reboot the machine after a hostname change is my advice.

  4. Cockpit is a very useful project, I’ve discovered this tool in the past few weeks and I’m enjoying it. What a pity that cockpit is less tested on Ubuntu, this makes it a little problematic for the implementation in an etherogeneous infrastructure.

    Useful article Paul, have a nice weekend 😉

  5. kapostol

    I made a clean install of Fedora Workstation 24 yesterday after formatting Windows 7. During the installation i had to set the host name. The initial was localhost.localdomain. I changed to something else, a name from mythology, without adding anything else.
    My computer is connected along with another computer to a single modem.
    Is that fine, or i have to change something?

    • Sebastiaan Franken

      Setting a FQDN isn’t required (as in: the part after the dot, in the example case .localdomain). It helps if you have a large network, or if your (internal) network is (semi-) open to the outside world. For most desktop uses just setting a nice name is enough.

  6. Erik B.

    I have just been editing /etc/hostname manually. What is the downside now of that?



  7. David

    If anyone should be interested, I once amused myself greatly trying to set the hostname persistently on an EC2 instance as it gets lost by default at reboot. Here is what transpired:

    And here is the silly little script that prints the hostname using all the silly little ways that must have sedimented over the ages:

  8. Thanks so much for this post! I really hope they make more tutorial type posts.
    Or have a way to publish it on fedora software or something.

  9. anon

    /etc/hosts is sometimes needed for some services too

  10. Petri

    Because – at least me – some people are lazy, it might be good to know: “hostnamectl” alone does the same than “hostnamectl -status”.

  11. imajuk

    I found setting the hostname is pretty simple this way – open Settings, then System, then Details. There is field Device name. Write there your hostname. After you can check changes with ‘hostnamectl’ or ‘cat /etc/hostname’.

  12. Hi! Thank you. Simple and useful. Specially because it`s really easy to miss this part, setting hostname, during installation.

  13. German

    Me gusta este tipo de contenido. Así aprendo más rápido.

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions