
How do you set the hostname of a Linux machine? It used to be you just put it in the file /etc/hostname. Now, at least on CentOS, the SystemD way is to use the hostnamectl command. There are other ways (GUI and TUI) but I think hostnamectl is the real way. This lets you set the real, pretty, and transient name of the host. I didn't know those existed. In fact, there are lots of other options. The text space of the hostnamectld is 272K (40% larger than the text editor I use and 2.5 times the size of the hostname command). You can even change the hostname of other machines and hostnamectl will use ssh to accomplish this. I don't see why it is hostnamectl's job to know how to ssh. I will admit that the good old days were not that wonderful. The hostname(1) manpage lists: hostname - show or set the system's host name domainname - show or set the system's NIS/YP domain name ypdomainname - show or set the system's NIS/YP domain name nisdomainname - show or set the system's NIS/YP domain name dnsdomainname - show the system's DNS domain name and a lot of flags. And there's uname -n. I remember uuname but that is no longer standard -- you'd have to install uucp to get that. Every ethernet interface can have one or more DNS names. And plenty more that I don't remember. Kerberos? SMB? Hesiod? To be honest, what bothers me is that there seem to be several different models of what a hostname is. It would be nice if we actually could delete some of these interfaces, and merge some others, leaving behind only one model. Maybe the SystemD model is that one.