This question already has an answer here:
First, what is the correct way to change the hostname in Linux ? I followed some steps on the internet and sometimes it does not take effect. Besides, the new hostname does not appear when I ping my PC from another one on the same LAN. So how to change the host name and make it appear on the LAN ?