This post helps in learning how to set up a persistent and static hostname on Linux. In Linux, a static hostname is a set name for your computer that you may use to identify it on a network, but a persistent hostname makes sure the static hostname doesn’t change even when your computer restarts.
Let us follow the steps:
- Configure a static hostname:
- Type the following command to see the hostname of the system:
$ hostname
- You can also change the system name temporarily by using the hostname command. Here is an illustration:
$ hostname example1.example
- This is a momentary modification. The modifications will be undone when you reboot.
- Type the following command to see the hostname of the system:
- Configure a persistent hostname:
- You can directly modify the configuration file at “/etc/hostname” or use the “hostnamectl” command to make a permanent change to the hostname.
- Use the “hostnamectl” command to alter the hostname permanently as an example. This proves the change:
Set-hostname server1.example1.com $ hostnamectl
- After running the command, make sure you use the hostname command to confirm the modification.
- You may verify the item by displaying the contents of the /etc/hostname file.
You are now familiar with how to configure a static and persistent hostname on Linux. If you face any difficulty, feel free to seek assistance from our support team.