How to fix

How to set hostname in Linux

In computer networking, a hostname (archaically nodename) is a label. It’s assigned to a device connected to a computer network. That is used to identify the device in network.

sudo hostname {{ new hostname }} 

– Will work till system restart.

Define hostname permanently:

For newer distributives, that uses SystemD init system:

sudo hostnamectl set-hostname {{ new hostname }}

Older versions uses SysV init system:

sudo echo {{ new hostname }} > /etc/hostname

Add to /etc/hosts

sudo echo " {{ new hostname }}" >> /etc/hosts

Now you can see in your prompt selected hostname. Also, you can connect (at least locally) to this node using hostname.

In the most cases users don’t use hostnames for communications. Sometimes they even don’t know the label of their computer. But it’s nice to be able to see hostname in prompt.