11

I am studying RHEL 7 and have some questions.

Using hostnamectl command, I am getting information of RHEL 7 hostname and other.

If i want to change hostname there are some options using hostnamectl:

[root@linux7 ~]# hostnamectl set-
set-chassis     set-deployment  set-hostname    set-icon-name 

To change hostname, static hostname set-hostname is used. So what about set-icon-name and --pretty and which particular file it get changed?

Below example is given:

[root@linux7 ~]# hostnamectl set-hostname Linuxindia
[root@linux7 ~]# hostnamectl set-icon-name mumbailinux
[root@linux7 ~]# systemctl restart systemd-hostnamed.service 

[root@linuxindia ~]# hostnamectl set-
set-chassis     set-deployment  set-hostname    set-icon-name   
[root@linuxindia ~]# hostnamectl set-hostname "hellolinux" --pretty
[root@linuxindia ~]# hostnamectl status 
   Static hostname: linuxindia
   Pretty hostname: hellolinux
         Icon name: mumbailinux
           Chassis: vm
        Machine ID: f3ffdd0447604e20a0a4278c56f4275b
           Boot ID: 70c3c85ec1fa4dceb5a7f52789eed524
    Virtualization: kvm
  Operating System: Red Hat Enterprise Linux Server 7.3 Beta (Maipo)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:beta:server
            Kernel: Linux 3.10.0-493.el7.x86_64
      Architecture: x86-64
[root@linuxindia ~]# 

Requesting to get some information on Transient hostname also.

cuonglm
  • 153,898

2 Answers2

12

Icon name is the machine identifying name according to XDG Icon Naming Specification.

When --pretty is used, the machine pretty hostname was set. This name is human readable name, is present to the user, not the machine. It does not have the limitation of internet domain name, you can use any valid UTF-8 name for it:

$ hostnamectl --pretty set-hostname "$(perl -CO -le 'print "\x{1f389}"')"
$ hostnamectl --pretty status

Note that while DNS allows domain name up to 255 characters, the hostname in Linux is limited to 64 characters only:

$ hostnamectl set-hostname "$(perl -le 'print "A" x 65')"
$ awk '{print length}' /etc/hostname
64

The hostname was stored in /etc/hostname,pretty name and icon name are stored in /etc/machine-info.

cuonglm
  • 153,898
3

The RHEL 7 Networking Guide provides some details concerning hostnames:

There are three classes of hostname: static, pretty, and transient. The “static” host name is the traditional hostname, which can be chosen by the user, and is stored in the /etc/hostname file. The “transient” hostname is a dynamic host name maintained by the kernel. It is initialized to the static host name by default, whose value defaults to “localhost”. It can be changed by DHCP or mDNS at runtime. The “pretty” hostname is a free-form UTF8 host name for presentation to the user.

Note: A host name can be a free-form string up to 64 characters in length. However, Red Hat recommends that both static and transient names match the fully-qualified domain name (FQDN) used for the machine in DNS, such as host.example.com. It is also recommended that the static and transient names consists only of 7 bit ASCII lower-case characters, no spaces or dots, and limits itself to the format allowed for DNS domain name labels, even though this is not a strict requirement. Older specifications do not permit the underscore, and so their use is not recommended. The hostnamectl tool will enforce the following: Static and transient host names to consist of a-z, A-Z, 0-9, “-”, “_” and “.” only, to not begin or end in a dot, and to not have two dots immediately following each other. The size limit of 64 characters is enforced.