Score:0

Who creates /etc/hostname

US flag

In a 20.04, after some upgrade /etc/hostname contains 'localhost' event hostnamectl working well and with hostname correctly set.

It's only appreciated that /var/log/syslog shows 'localhost' instead of real hostname.

Removing /etc/hostname file, no error is appreciated and, the question ¿what process requires and created this file?

Pilot6 avatar
cn flag
The person who installed the system has set a host name.
JMari avatar
md
Yes, correct. But what happens when host change the hostname? dhcp update properly hostnamectl but this file remains untouched. The evidence is all is running well without this file. Thanks for reply!!
JMari avatar
md
The "partial" answer is in man page about hostname : /etc/hostname Historically this file was supposed to only contain the hostname and not the full canonical FQDN. Nowadays most software is able to cope with a full FQDN here. This file is read at boot time by the system initialization scripts to set the hostname.
cn flag
https://www.freedesktop.org/software/systemd/man/hostname.html explains it all
Terrance avatar
id flag
Unfortunately your question is hard to understand. Are you wondering what the `/etc/hostname` file is used for? Are you asking about what application or update may have changed your `/etc/hostname` file from the name you had before to `localhost`?
JMari avatar
md
(Yes, I'm sorry, I apologize for my language, I'm not native.) The main question is about what network process (like network-manager) creates and uses this file because, after removing it or with a wrong content, everything seems to be going well. File /etc/hostname is not owned by any package: I assume is modified for a network script or maybe created at installation time.
JMari avatar
md
As @Rinzwind says (thanks), /etc/hostname filled in the macine installation, with systemd.hostname kernel parameter or transient hostname by systemd-hostnamed service. But in month running a set of machines, with no systemd errors, neither of them have changed /etc/localhost file. Removing this file, I understand that transient hostname obtained by DHCP has the priority and with no unwanted effects
JMari avatar
md
In 22.04.* the installation hostname is in /etc/hostname, no DHCP updates.
Score:0
US flag

As @Rinzwind says (thanks), /etc/hostname filled in the machine installation, with systemd.hostname kernel parameter or transient hostname by systemd-hostnamed service.

But in month running a set of machines, with no systemd errors, neither of them have changed /etc/hostname file.

Removing this file, the transient hostname obtained by DHCP has the priority and with no unwanted effects.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.