this post was submitted on 27 Feb 2026
77 points (98.7% liked)

Linux

63814 readers
1148 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
 

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 24 comments
sorted by: hot top controversial new old
[–] JasonDJ@lemmy.zip 12 points 2 weeks ago (1 children)

Isn't this what hostnamectl is supposed to handle?

[–] jokeyrhyme@lemmy.ml 4 points 2 weeks ago

it modifies /etc/hostname for you, but doesn't seem to touch /etc/hosts

i still prefer hostnamectl, but i'm now unsure of what benefit it offers over editing /etc/hostname directly

[–] ark3@lemmy.dbzer0.com 9 points 2 weeks ago (3 children)
[–] non_burglar@lemmy.world 5 points 2 weeks 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

[–] MonkderVierte@lemmy.zip 4 points 2 weeks ago (1 children)
[–] racketlauncher831@lemmy.ml 1 points 2 weeks ago

Laughs louder in Void, Gentoo, and Devuan.

[–] jokeyrhyme@lemmy.ml 3 points 2 weeks ago

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

[–] otacon239@lemmy.world 9 points 2 weeks ago* (last edited 2 weeks 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.

[–] luthis@lemmy.nz 7 points 2 weeks ago (2 children)

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

[–] jokeyrhyme@lemmy.ml 5 points 2 weeks ago (1 children)

no, you might have misunderstood

/etc/hosts is not where the hostname is configured

/etc/hostname for the actual hostname, and a mapping in /etc/hosts pointing it at a 127.x.x.x address

[–] luthis@lemmy.nz 2 points 2 weeks ago

Ohh right yes. I only ever touch hostname once during install and then only hosts after that

[–] MonkderVierte@lemmy.zip 5 points 2 weeks ago* (last edited 2 weeks ago)

Probably a systemd-somethingd.

Edit: yup

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

[–] limelight79@lemmy.world 5 points 2 weeks ago* (last edited 2 weeks ago) (2 children)

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.

[–] triplenadir@lemmygrad.ml 1 points 3 days ago

.local is usually avahi / bonjour - could be some machines are running it, others aren't

[–] p03locke@lemmy.dbzer0.com 4 points 2 weeks ago (1 children)
[–] limelight79@lemmy.world 1 points 2 weeks ago

I use DHCP for everything, even my server, with a reserved IP address in the router for the server and my desktop and a few other things I don't want to move around (printers, some IoT things, Home Assistant, etc.).

I think the issue is the bridge interface I have to set up for Home Assistant.

[–] arty@feddit.org 4 points 2 weeks ago (2 children)

You guys are having own hostname in hosts file?

[–] itmosi@sh.itjust.works 2 points 2 weeks ago

Never, there's no need for it. I can reach it with localhost or 127.0.0.1, so why would I even put it in?

[–] jokeyrhyme@lemmy.ml 2 points 2 weeks ago

seems like a pretty common practice across Linux distributions

/etc/hostname for the actual hostname, and a mapping in /etc/hosts pointing it at a 127.x.x.x address

[–] monovergent@lemmy.ml 4 points 2 weeks 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 2 points 2 weeks ago (1 children)

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)

[–] jokeyrhyme@lemmy.ml 1 points 2 weeks ago

i'm guessing a few things somehow consume /etc/hosts mappings without going through nss /shrug

[–] Hawke@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks 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.