A pretty hostname avoids most of the limitations of other hostname types, giving users more freedom when naming their systems.
In this tutorial, we will show you how to set up a pretty hostname for a Linux system in two different methods.
Types of hostnames
- Static hostname: The standard hostname.
- Transient hostname: A dynamic hostname set by the system kernel. It is the same as the static hostname, but DHCP and mDNS servers can change it.
- Pretty hostname: A free-form hostname to describe the system to other users within the network.
NOTE: Pretty hostnames can use any valid UTF8 symbol. on another hand, Static hostnames follow the same restrictions as Internet domain names. They have a maximum length of 64 characters and allow the use of letters, hyphens , underscores, and periods.
Set Up a Pretty Hostname
Using the hostnamectl command
- Use the hostnamectl Linux command to set up a pretty hostname with the command below:
hostnamectl set-hostname [name] --pretty
hostnamectl set-hostname "Unixcop Test " --pretty
- Now, Check your new hostname by using the hostnamectl
Manually with editing the /etc/machine-info config file
Linux savess pretty hostnames in the /etc/machine-info config file.
NOTE: The /etc/machine-info file also contains system information, such as icon names, chassis types, deployment environment, and system location.
NOTE: Note that /etc/machine-info generates once you change one of the settings it stores. If there haven’t been any changes to these settings, this file will be absent from your system.
- Create the file if it is absent
- Open the file with a text editor.
- Add the pretty hostname as shown below.
- Save and quit
- Use the hostnamectl command to verify the new pretty hostname
In this tutorial, We have illustrated how to set up a pretty hostname on your Linux system.