Change hostname in Debian As root - run the command: hostnamectl set-hostname NEW-HOSTNAME Remember that the hostname can only contain letters, digits, and dashes.