How to change the hostname in Linux

CentOS/Ubuntu

  • Type “hostnamectl set-hostname your-new-hostname”
  • Type hostname to check it