Why are you rebooting?
I want to change the hostname on my Ubuntu-based MacBook Air. It’s easy
to find advice and tips on almost anything by googling the question. I’m
use to the hostname
command, but that only lasts the session. I can
change /etc/hostname, but that file is used at startup. So much of the high google
juice content suggests a reboot, such as this nixCraft.
Why does so much of the Ubuntu advice I find nowadays say to change something then reboot?
I think there are two reasons.
First, much of the advice out there is clickbait crap. Look around enough and you’ll see the same content in different wrapper. That’s just a low-paid person copying whatever they found first then moving on to the next thing. But, it also shows up in some places where I expect more:
*DigitalOcean fails to correct it (and several other places). *The accepted answer on AskUbuntu’s question How do I change the hostname without a restart? says you have to restart.
A less popular answer on AskUbuntu
shows how to change it immediately and persist it through a reboot. This
sets the hostname to enhydra
:
This is really the same as using hostname
to set the session hostname,
but also putting that same value in /etc/hostname so it’s used on
the next startup.
Along with that, you need to ensure that new hostname is in /etc/hosts, which you have to do on your own. When the system wonders what address it should use, there needs to be a line pointing it to the loopback address:
An even less popular answer points to the service:
Second, without any proof for this, I think that many people are coming from environments where you were forced to restart. I once worked in a room where I’d need to leave at 1:30pm to escape the sound of all the Windows NT machines going through their daily reboot. Those environments weren’t made for computer-savvy people, so if something—anything—gets out of wack, reset everything and try again. Sadly, I think macOS and its users are moving in that direction.
Unix isn’t supposed to be like that. Many Unix devotees pride themselves on their uptime—how long it has been since the last restart. This value could be years. If you needed to reset something, you could restart that service. However, you not only had to know that you needed to restart something but what that was. For example, you don’t need to take down an Apache server to get configuration changes; you can tell it to re-read its configuration.
But, when I read most of the other advice for unix tasks, I notice that it’s more about instructions about their editor than the actual task. When you have to instruct people at such a low level, you get what you get. Reboot is probably the easiest thing. For instance, if you change the hostname, you probably need to adjust xauth so windowing still works (I’m a terminal man myself). Still, that doesn’t necessitate a reboot. It’s just something you don’t ever remember how to do because it’s so rare.
Now, there is some merit to restarting: you can see if what you did works across the restart. However, that’s a different beast. You don’t need to do that to get the effect.