0

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!

6
  • What is the content of /etc/hosts?
    – Milliways
    May 6, 2023 at 3:06
  • Per the man-page that's hostnamectl --transient --static hostname hg There is no ``set-hostname` command to hostnamectl See man 1 hostnamectl You can always do it the old way too # hostname hg then # echo "hg" > /etc/hostname and update /etc/hosts to contain the line 127.0.0.1 hg.yourdomain.tld localhost hg and do the same for the ::1 address for IPv6 loopback. May 6, 2023 at 7:56
  • I disagree. The manpage for hostnamectl very clearly identifies "set-hostname NAME" as valid; it's the second command listed, after status.
    – RoUS
    May 6, 2023 at 8:11
  • And /etc/hosts includes localhost for IPAs 127.0.0.1 and ::1. Which is as it should be The local address will always be there, and should always be named localhost. hg is known in DNS for the non-local address, so also assigning it in /etc/hosts to 127.0.0.1 will 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 to localhost, and why? /etc/hostname does contain hg.
    – RoUS
    May 6, 2023 at 8:16
  • It's an issue because the .bash_history file name includes the hostname, as does the bash prompt. Having those both use localhost defeats the purpose, but I believe it's the value of HOSTNAME envariable 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, 2023 at 3:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.