You can use the hostnamectl command to view the host name. In centos, you can use the hostnamectl command to query the host name. The function of this command is to manage the host name. When this command does not take parameters, you can view the host name information. The syntax is hostnamectl.