The name of the server or computer is known as the hostname. Users on a network use a hostname to define their identity. The hostname is set during the installation of the Linux distro, but you can change it according to your requirements.
Changing the hostname permanently on an operating system like CentOS or Fedora is a simple process in which you only need to edit a few system files. However, there are various approaches for changing the hostname in Fedora Linux. In this guide, we will explain different methods to change the hostname in Fedora Linux.
How to Change the Hostname in Fedora Linux
In Linux, there are three major types of hostnames:
- Static: The default hostname provided by the kernel used at system boot-up.
- Transient: The network configuration assignes the transient hostname, which is usually the same as the static hostname.
- Pretty: This hostname is defined by the user and can be descriptive and longer.
In this guide, we will include the approaches for changing all the above hostname in your Fedora machine.
Using the ‘hostname’ Command
The ‘hostname’ command-line utility is used for changing the hostname temporarily. First, run the following command to check the current transient hostname.
Now, let’s change the hostname from ‘prateek’ to ‘linuxhint’ using the following command:
You can verify whether the hostname has been changed by running the ‘hostname’ command again.
Using ‘hostnamectl’ Command
The ‘hostnamectl’ is a more feature-rich utility than the ‘hostname’ command. Using this command, you can check the static hostname of your Fedora Linux.
The above results also display whether the hostname is static or transient. However, you can use the hostnamectl command to see a static, transient, or pretty hostname by specifying the following options:
For static hostname:
For static transient:
For static pretty:
Now, run the below command to change the hostname permanently:
For example, let’s change the static hostname in ‘linuxhint’ to ‘Fedora’ using the following command:
Using /etc/hostname file
You can change the hostname permanently from the ‘/etc/hostname’ file. So first, open this file using any editor of your choice:
The current hostname is linuxhint, but we can edit and change it accordingly.
From the Settings
If you prefer not to to use the command, you can go to the settings from the Application Menu.
Now, go to the About section, and please change the name as per your requirements.
Here you can see the current or static hostname of your system. To change it, replace the existing hostname in a device name field with a new hostname and save the changes.
Conclusion
We described the complete methods you can use to change the hostname in Fedora Linux. There are mainly three types of hostnames in Linux: transient, static, and pretty. Fedora Linux provides the ‘hostnamectl’ command for changing the hostname permanently. Alternatively, you can also possibly edit the /etc/hostame file to change the hostname.