The Lynis security audit tool has flagged up the following:
Split resolving between localhost and the hostname of the system
The online explanatory note says:
For proper resolving, the entries of localhost and the local defined hostname, could be split. Especially with some middleware and some applications, resolving of the hostname to localhost, might confuse the software.
You should always have a hostname set. If not then the IP assigned by your network does not have a specific hostname to refer to and it becomes ambiguous whether localhost refers to the 127.0.0.1 address or the 192.168.nnn.nnn address assigned to network interface. Apps that use hostname lookups rely on the hostname value being there and accurate, especially if the host can be identified by dns.
Using hostname will display the current hostname and sudo hostname [your hostname] will enable you to set the hostname (FQDN) that is the default hostname for that machine. Once the hostname is set all apps that do hostname lookups will be able to properly identify the machine.
I believe sudo hostname only sets the current hostname, and does not persist across reboot. Edit /etc/hostname for it to be permanent.
You can also use hostnamectlto show some additional information sources, including the “pretty name” (which will be displayed on the Workstation login screen, and which can contain spaces, unicode, whatever). sudo hostnamectl your_hostname will set all of the current (“transient”) name, the persistent name (systemd calls it “static”), and also the pretty name. You can also set them separately, like sudo hostnamectl --pretty "My Computer 💻".
(hostnamectl isn’t doing anything magic, by the way — it’s calling the same system calls as hostnamefor the runtime name, and writing the others to /etc/host and /etc/machine-info. It’s just conveniently putting it all in one place.)