HostOnNet Blog

Setting hostname On CentOS 7 Server

Looking for Linux Server Admin or WordPress Expert? We can help.

CentOS 7 come with a command hostnamectl to query and change the system hostname and related settings.

[root@localhost ~]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-server
           Chassis: server
        Machine ID: 78f871402a1e423eaf954e546eac2ce9
           Boot ID: cd0c96ae86534757b5982569dbd885bc
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-514.el7.x86_64
      Architecture: x86-64
[root@localhost ~]# 

Set hostname

To set hostname, run

hostnamectl set-hostname HOST.YOUR-DOMAIN.EXTN

Example

[root@localhost ~]# hostnamectl set-hostname server2.hosthat.com
[root@localhost ~]# hostname
server2.hosthat.com
[root@localhost ~]# 

See also HostName

Posted in CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.