60
submitted 1 day ago by jokeyrhyme@lemmy.ml to c/linux@lemmy.ml

hehe, so ... if you ever change the hostname of a Linux machine, you really really ought to double-check /etc/hosts to make the same hostname change there

it's surprising just how much will break if a machine's own hostname isn't resolvable to a 127.x.x.x address :P

top 15 comments
sorted by: hot top controversial new old
[-] limelight79@lemmy.world 1 points 18 hours ago* (last edited 18 hours ago)

This reminds me... My server demands to be known as hostname.local on my network. The other machines just respond to just hostname. I really should figure out why that is.

[-] p03locke@lemmy.dbzer0.com 1 points 17 hours ago

Domain search suffixes

[-] luthis@lemmy.nz 4 points 1 day ago

There's another way to change the hostname that isn't etc/hosts?

[-] MonkderVierte@lemmy.zip 3 points 23 hours ago* (last edited 23 hours ago)

Probably a systemd-somethingd.

Edit: yup

[-] JasonDJ@lemmy.zip 7 points 1 day ago

Isn't this what hostnamectl is supposed to handle?

[-] arty@feddit.org 1 points 1 day ago

You guys are having own hostname in hosts file?

[-] ark3@lemmy.dbzer0.com 9 points 1 day ago
[-] MonkderVierte@lemmy.zip 2 points 23 hours ago

Laughs in Alpine.

[-] non_burglar@lemmy.world 3 points 1 day ago

I know this is the preferred way to do it now, but I sometimes worry that abstracting where things are configured in an is that configures everything in a file.

You used to only have to check two places to change a hostname.

Oldmanyellsatsky.jpg

[-] jokeyrhyme@lemmy.ml 3 points 1 day ago

yep, I used that command to modify the hostname, rather than edit /etc/hostname directly

[-] otacon239@lemmy.world 9 points 1 day ago* (last edited 1 day ago)

Interesting. I’ve changed my hostname on a few machines throughout the past and never ran into this. Good to know if I ever run into this in the future.

Nothing is worse than waiting for sudo to time out. I forget how long it would take, but it always feels like ages.

[-] monovergent@lemmy.ml 4 points 1 day ago

Lost my mind a few years ago over this quirk. Now I always change both files when I want to change the hostname.

[-] alastel@lemmy.ml 1 points 1 day ago

If you have myhostname set for hosts in /etc/nsswitch.conf it shall take care of this for you (should be the default on most systemd distros I believe? not sure)

[-] Hawke@lemmy.world 1 points 1 day ago

It’s always been wild to me how the seemingly-simplest change (“what is the name of this computer” has so many little gotchas and quirks.

this post was submitted on 27 Feb 2026
60 points (98.4% liked)

Linux

63339 readers
912 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS