I swapped-in a new motherboard, cpu, and renamed a machine. The old machine name was bulldozer, and the new mchine name is skylake. I used hostnamectrl --static according to How to permanently change hostname in Fedora 21 since the machine is Fedora 25.

When the machine boots, systemd is still using the old name:

skylake:~$ sudo dmesg | grep bulldozer
[    1.085387] systemd[1]: Set hostname to <bulldozer>.
skylake:~$ hostname

According to the honamectrl man page, it sounds like --static is supposed to do it: "... the static hostname which is used to initialize the kernel hostname at boot ...".

Grepping /etc does not reveal any hits for the old name:

skylake:~$ sudo grep -R bulldozer /etc/ 2>/dev/null

I also tried /sbin/sysctl -q -w kernel.hostname=skylake according to Correctly setting the hostname - Fedora 20 on Amazon EC2. But it did not work, either.

How do I change the host name for systemd?

  • Please demonstrate that the /etc/hostname, and indeed the /etc and / filesystems, that you are looking at with grep are the same ones that process #1 running systemd saw before any filesystems were mounted, bind mounts were made, roots were changed, and so forth.
    – JdeBP
    Commented Mar 11, 2017 at 10:02
  • @JdeBP - Certainly. How would you like me to do it? Or how does one provide the information?
    – user56041
    Commented Mar 11, 2017 at 13:56

3 Answers 3


According to this article, you should run hostnamectl set-hostname name where name is your desired hostname. I presume you should run this as root.

  • Thanks, but no joy. Its amazing how far we've come since the original hostname command. The original command worked great for years. After all the improvements, we can no longer set the hostname. Classic over engineering by a bunch of programmers...
    – user56041
    Commented Mar 11, 2017 at 7:12
  • 2
    It is ironic that the other answer here actually demonstrates what they are engineering this for. It's the how-to-do-this-by-writing-the-file approach, in a way that attempts to allow this to be done by an unprivileged user. It makes a common mistake in the use of sudo and does not in fact work. The hostnamed/hostnamectl system is engineered so that both unprivileged and privileged users run the same command, with hostnamed consulting the "policy kit" mechanism for authorization checks. So M. Leuenhagen's presumption is incorrect.
    – JdeBP
    Commented Mar 11, 2017 at 9:58

This is an awful answer, but its provided for completeness. The kernel was updated today. The old Fedora kernel was 4.9.13-200.fc25.x86_64. The new kernel is 4.9.13-201.fc25.x86_64.

After the kernel updates, I manually delete the old kernel from /boot using rm. This is a standard procedure for me on Linux (I always perform it to remove unwanted cruft). In this case, I ran:

su -
cd /boot
rm -rf *4.9.13-200*
rm -rf .*4.9.13-200*

After manual removal, I regenerate the Grub menu and then reboot. This is also a standard procedure for me on Linux.

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

After the reboot, the old name was no longer present:

$ dmesg | egrep -i '(bulldozer|skylake)'
[  0.065941] Performance Events: PEBS fmt3+, Skylake events, 32-deep LBR, full-width counters, Intel PMU driver.
[  1.096957] systemd[1]: Set hostname to <skylake>.

So, something affected the hostname used by systemd, but I am not sure what it was.

I tried regenerating grub.cfg previously, so I'm not convinced its the answer. I'm guessing a package triggered the correction, and after the reboot I observed things were as expected.


This method is deprecated in current version of systemd, but I'm keeping it here as reference for some of the comments.

The quickest way would be sudo echo -e "bulldozer" > /etc/hostname followed by a reboot.

Systemd's network stack should pick it up and apply it on startup.

You can also use a text editor and create/edit /etc/hostname manually. (I recommend nano, but you need to install it manually on fedora first)

Systemd's hostnamectl is supposed to be the way to do it today, it seems.

  • cat /etc/hostname shows the expected name.
    – user56041
    Commented Mar 11, 2017 at 4:02
  • This unfortunately does not work (or it never worked for me with systemd).
    – Jakuje
    Commented Mar 11, 2017 at 15:24
  • @Jakuje on Arch Linux, which uses systemd, modifying /etc/hostname does successfully change the hostname. Commented Mar 13, 2017 at 14:31

You must log in to answer this question.