Change Hostname on Fedora 35 - Step by step guide ?

Change Hostname on Fedora 35 - Step by step guide ?

 

A hostname is a human-readable string that helps people refer to a computer by a familiar name. As a system administrator, it is imperative to have a short but recognizable hostname to separate the server machines from each other. Often, a hostname is set during the installation process, but there are times when it needs to be changed.

Here at Fixwebnode, as part of our Server Management Services, we regularly help our Customers to perform related Fedora system configuration queries.

In this context, we shall look into how to Change the Hostname on Fedora 35.

 

Steps to Change Hostname on Fedora 35

1. Perform System Update

To begin, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:

$ sudo dnf upgrade
$ sudo dnf update

 

2. Show the Current Hostname

You can check the current hostname by using either the hostname or hostnamectl command:

$ hostnamectl

The output will look like below which shows the static and transient hostnames:

Static hostname: localhost.localdomain
Transient hostname: fedora
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 65fc9e69d00701bmwe46f31bc527888ed1
           Boot ID: 81ac938872bae0bmwe46cb288841ac93
  Operating System: Fedora 35 (Workstation Edition)
       CPE OS Name: cpe:/o:fedoraproject:fedora:35
            Kernel: Linux 5.15.10-200.fc33.x86_64
      Architecture: x86-64

To see the current static, transient, or pretty hostname, you can use the hostnamectl command with options, such as:

$ hostnamectl --static
$ hostnamectl --transient
$ hostnamectl --pretty

 

3. Change Hostname on the system

You can change the hostname of the Fedora system using the following command. For example, you need to set the computer hostname to fedora.fixwebnode.com:

$ sudo hostnamectl set-hostname fedora.fixwebnode.com

 

4. Confirm the Hostname change

Once changing the Hostname, verify it by typing the hostnamectl command. The result shows the system information along with a new static hostname:

$ hostnamectl

The output will look like this:

Static hostname: fedora.fixwebnode.com
Transient hostname: fedora
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 65fc9e69d00701bmwe46f31bc527888ed1
           Boot ID: 81ac938872bae0bmwe46cb288841ac93
  Operating System: Fedora 35 (Workstation Edition)
       CPE OS Name: cpe:/o:fedoraproject:fedora:35
            Kernel: Linux 5.15.10-200.fc33.x86_64
      Architecture: x86-64

 

[Need to fix Fedora system issues ? We can help you. ]

 


Conclusion

 

This article covers how to change and set the hostname on your Fedora 35 system. In fact, You can use the hostnamectl command to display or set the Fedora Linux system's host name.

 

How To Uninstall hostname on Fedora 35 ?

To uninstall only the hostname package we can use the following command:

$ sudo dnf remove hostname

 

How do I change Hostname Permanently on the Fedora Linux ?

1. Edit the file /etc/hostname, execute the command:

$ sudo vi /etc/hostname

2. Delete the existing name and replace it with a new name:

fedora28-fixwenode

3. Save and close the file. You may also need to edit the /etc/hosts file, enter:

$ sudo vi /etc/hosts

4. Find all references to server1 and replace with server2:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.122.49 fedora28-fixwenode

5. 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.

 


icon

Sign up to our Newsletter

...and get one free support ticket.