How to change hostname in Fedora Linux permanently

Originally published at: https://www.cyberciti.biz/faq/howto-change-hostname-in-fedora-linux-permanently/

How do I change the hostname of a Fedora Linux system permanently using the command line tools from localhost to fedora28-nixcraft? How do I change hostname in Fedora Linux permanently from localhost.localdomain to fedora28-nixcraft?

  1. You can create a file “/etc/hostname”.

vim /etc/hostname
fedora28-nixcraft

  1. Need to restart the service for this to take effect.

#systemctl restart systemd-hostnamed

Another way is to use Command to Change hostname:

  1. #hostnamectl set-hostname fedora28-nixcraft

This will create the file for you and restart the service automatically.