How to change hostname in Centos

Commands to change hostname in Centos

sudo sed -i 's/<old name>/<new name>/g' /etc/sysconfig/network /etc/hosts
sudo hostname <new name>

And after log of and log in – the hostname will be

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.
Continue reading