If you need to change your system’s hostname, use hostname or hostnamectl commands.

hostname servername
hostnamectl set-hostname servername

You can add the hostname to these 2 files and reboot.

vi /etc/hostname
vi /etc/hosts
reboot

Without a reboot. Add the hostname to these 2 files.

vi /etc/hostname
vi /etc/hosts

And add a hostname entry to 127.0.0.1 in /etc/hosts.

127.0.0.1 servername

That’s all she wrote.