Sudo and SMB run slower after changing server name

Oct 7, 2024

A week ago, I started transitioning from using my old laptop as a server to a brand new tower. The old one worked fine, but it looked janky, hackney, unprofessional. Not too mention, it got hit by my roomba all the time, disconnecting the hard drive connecting from a dock using a USB cable. The new one has 4-core CPU i3-8100 instead of 2-core i3-4130U, and has a higher clock too so it is faster. Other than that, it still runs Debian 12 like the last one.

However, I named the new one when installing bach-server-2 instead of the old name, bach-server, because at the time, I was moving back and forth between the two. Now that was finished, I renamed the new one bach-server, but something happened. The SMB/Samba connection I used for file transfer seemed slower. Any command run on sudo seemed sluggish, like the part where you enter the password showed up late. And it turned out, according to this post from Server Fault, and [this] (https://www.linuxquestions.org/questions/linux-newbie-8/fedora-11-sudo-has-a-20-second-start-delay-732291/#post3575840) from Linux Questions, it happens when I change the hostname like

sudo hostnamectl set-hostname bach-server

without changing the hostname in /etc/hosts, resulting in slowness.

So by changing the hostname, and the hostname in /etc/hosts, everything works out again.