Pretty, Static, Transient Hostnames in Linux

What are the different classes of hostname?

Hostname is the name given to machine in the network for identification. In Linux there are three classes of hostname available.

  • Static Hostname
  • Transient Hostname
  • Pretty Hostname

Static Hostname

Static hostname is the ordinary traditional hostname set by a user, the entry can be seen in /etc/hostname file. Static hostname have a restriction, it can only contain a-z,A-Z,0-9, "-","_"and ".". The static hostname shouldnot begin and end with ".",and shouldnot have two adjascent(nearby) "."

Static hostname can be set by:

hostnamectl set-hostname <host-name>

Transient Hostname

Transient hostname is a dynamic hostname set by system kernel. By default, transient hostname will be same as static hostname, but it can/will get changed runtime by DHCP and mDNS servers. Transient hostname is also operator configurable and can be configured by below command

hostnamectl set-hostname --transient <hostname>

Pretty Hostname

Pretty hostname will be defined by user to describe their system. Unlike transient and static hostname, pretty hostname is a free form hostname, which can have any valid UTF8 characters. Since Linux imposes a 64 characters limit for hostname, this limitation is applicable for pretty hostname also. To set pretty hostname, below command can be used.

hostnamectl --pretty set-hostname <hostname>

Hostnamectl command and output

  • Static, transient, pretty hostname is set using below three commands.
[root@lc ~]# hostnamectl set-hostname Linux-Data-Hub
[root@lc ~]# hostnamectl set-hostname --transient Transie-LDH
[root@lc ~]# hostnamectl --pretty set-hostname "$(perl -CO -le 'print "\x{1f389}"')"
  • If you see the above pretty hostname command, im trying to put 🎉 as hostname
  • hostnamectl output shows all the three hostnames

Pretty, Static, Transient Hostnames in Linux


Search on LinuxDataHub

Leave a Comment