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