How to change /etc/hostname and /etc/hosts?

 I have just installed Ubuntu Server.

 Neither /etc/hostname nor /etc/hosts are in standard format. To wit, /etc/hostname is not

linux
but rather
e[?12$pst.localdomain

 How do I change it and /etc/hosts to my desired hostname?

sudo hostnamectl set-hostname my-host-name

etc/hosts should be something like

cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       my-host-name

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
1 Like

That was what I sought.
Thanks!

1 Like

The netplan changes in bionic are a pain as the change is new to do exactly the same as the old.
Guess I will get there also but threw me slightly