CentOS 7 Set Hostname

Use the following to query and set the hostname of a CentOS 7 host.

Command syntax:

sudo hostnamectl status
sudo hostnamectl set-hostname NAME --static

Example output:

[mikeb@vm02 ~]$ sudo hostnamectl set-hostname vm02 --static
[mikeb@vm02 ~]$ sudo hostnamectl status
[sudo] password for mikeb:
   Static hostname: vm02
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 2be8ed......................42c2
           Boot ID: 1deeaf......................c14f
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.4.5.el7.x86_64
      Architecture: x86-64

Advertisement