On Linux, you can change the hostname by using the hostnamectl command.

How to Set the Hostname on Linux

sudo hostnamectl set-hostname <new-hostname>

For example:

sudo hostnamectl set-hostname server1

At this point, you will need to logout and back in to see the changes have taken effect.