How do I change what my computer is called on the network in Linux?

This is called the “hostname”. The change is very simple, as the hostname is stored in a text file. That file is /etc/hostname (pronounced et-see host-name). Here’s mine, which I’ve changed from “Yoga” to “Yo-Yo-Yoga” (I use an editor called vim, which is ancestor of vi, which is not particularly user-friendly, but it’s damned powerful. Use whatever editor you like by changing the “vim” part to whatever, like “gedit” or “nano”):

sudo vim /etc/hostname

(Note: hostnames must start with a letter and can contain only letters, numbers, and hyphens.)

Next, change any occurrence of the original hostname to the new one in /etc/hosts. Like this:

sudo vim /etc/hosts

Now, to make the change take effect, either reboot (guh!) or — in my Ubuntu 21.04 case — use hostnamectl. (Other distributions and older versions of Ubuntu use different mechanisms; look up “what service do I use to reset hostname in [your Linux distribution]”.) Here’s what I did:

sudo hostnamectl set-hostname Yo-Yo-Yoga

Where “Yo-Yo-Yoga”, as we all know by now, is my new, preferred hostname. Yours will likely be different, like “Hacker-Station-Delta” or “Party-Machine”.

Note that if you use hostnamectl without changing those files, then the next time you reboot, your computer will be named whatever is still in those files.

You can test the new hostname with the command “hostname”, like this:

I hope that was a lot of fun for all of you. I sure got a laugh out of it. In fact, I’m going to keep my hostname like this for a while. See you on the network!