How to change hostname in Linux Mint

Recently I changed hostname in my Linux Mint desktop and then I got the error each I tried to run something with “sudo”, for example:

$ sudo sed -i 's/maya/nadia/g' /etc/apt/sources.list
sudo: unable to resolve host garage

It means that I didn’t change hostname appropriately.

So in addition to:

sudo hostname 

I also needed to run this:

sudo sed -i 's///g' /etc/hosts
sudo sed -i 's///g' /etc/hostname

that’s it