What is hostname?

A hostname is nothing but your computer or server name. One can use the hostname to identify and define itself on a network. For example, hostname www13 indicates a web server. Sometimes you setup hostname as a fully qualified domain name (FQDN) 

How To change hostname in Fedora Linux server

Steps to change your hostname on Fedora Linux:

  1. Login to your server: ssh user@server-name
  2. Become a root user: sudo -s or su -
  3. Run command: hostnamectl set-hostname new-name

Let us see steps in details to change a system’s hostname i.e. rename a computer/server name when using a Fedora Linux based system.

Find your current computer name

Type the following hostname command or hostnamectl command:
$ hostname
Sample outputs:


$ hostnamectl
Sample outputs:

   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: c86ab4f4c14c435baff0597747b349d9
           Boot ID: 2145ab2be9de49b6bca1837bb8d5a2f8
    Virtualization: kvm
  Operating System: Fedora 28 (Server Edition)
       CPE OS Name: cpe:/o:fedoraproject:fedora:28
            Kernel: Linux 4.16.3-301.fc28.x86_64

Fedora change hostname

Let us change hostname in Fedora Linux. For example, change hostname to fedora28-nixcraft, enter:
$ sudo hostname fedora28-nixcraft
$ hostname

Sample outputs:


As compared to hostnamectl command, hostname command just read or set the hostname for the current session. It only exists for compatibility reasons. Hence, I recommend using the hostnamectl command as discussed below.

How do I change Hostname Permanently on the Fedora Linux?

Edit the file /etc/hostname, enter:
$ sudo vi /etc/hostname
Delete the existing name and replace it with a new name:


Save and close the file. You may also need to edit the /etc/hosts file, enter:
$ sudo vi /etc/hosts
Find all references to server1 and replace with server2:   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6	fedora28-nixcraft

Save and close the file. Please note that the host name is usually set once at system startup. This is an older method but still works on all versions of Fedora Linux.

How to set the hostname on Fedora Linux

With the latest version of Fedora Linux that uses systemd, it is possible to use a single command as follows:
# hostnamectl set-hostname {NameHere}
# hostnamectl set-hostname fedora28-nixcraft

Leave a Reply

Your email address will not be published. Required fields are marked *