Running Raspbian 11 Bullseye on a Raspberry Pi 3 Model B Rev 1.2
I noticed (from getting a different prompt when re-logging in at one point) that something keeps futzing with the "transient" hostname, resetting it to localhost:
# hostnamectl status
Static hostname: hg
Transient hostname: localhost
Icon name: computer
Machine ID: 5b33bf9eb66d440aaa7ed366eadef623
Boot ID: 4b4c2bfec1f247648d815598a227a284
Operating System: Raspbian GNU/Linux 11 (bullseye)
Kernel: Linux 6.1.19-v7+
Architecture: arm
If I manually set it myself, as with
# hostnamectl set-hostname --transient --static hg
and set up something to watch, something changes the transient hostname back to localhost, seemingly at random.
What's doing this, and how can I keep it from happening?
Thanks!
/etc/hosts? – Milliways May 06 '23 at 03:06hostnamectl --transient --static hostname hgThere is no ``set-hostnamecommand tohostnamectlSee [man 1 hostnamectl](https://man7.org/linux/man-pages/man1/hostnamectl.1.html) You can always do it the old way too# hostname hgthen# echo "hg" > /etc/hostnameand update/etc/hoststo contain the line127.0.0.1 hg.yourdomain.tld localhost hgand do the same for the::1` address for IPv6 loopback. – David C. Rankin May 06 '23 at 07:56hostnamectlvery clearly identifies "set-hostname NAME" as valid; it's the second command listed, afterstatus. – RoUS May 06 '23 at 08:11/etc/hostsincludeslocalhostfor IPAs127.0.0.1and::1. Which is as it should be The local address will always be there, and should always be namedlocalhost.hgis known in DNS for the non-local address, so also assigning it in/etc/hoststo127.0.0.1will not make things any more simple; rather the opposite, ISTM. What is deciding that the transient hostname should be changed from whatever it might have been tolocalhost, and why?/etc/hostnamedoes containhg. – RoUS May 06 '23 at 08:16.bash_historyfile name includes the hostname, as does thebashprompt. Having those both uselocalhostdefeats the purpose, but I believe it's the value ofHOSTNAMEenvariable at time of login that sets what will be used. So it needs to be something a) predictable, b) persistent, and c) specific to that particular host. Does that help? – RoUS Jun 13 '23 at 03:41cronjob to check and reset the name to the system's actual name, and not the navel-gazing valuelocalhost.