How to Preview Host Name of an Operating System in Linux CentOS 7

Posted on

Introduction

This is an article where the main focus is available as in the title of it. This article will show how to preview host name of an operating system in Linux CentOS 7. In order to preview the host name of an operating system in Linux CentOS 7, there is a specific command for it. Just execute that command in the command line interface. Usually, every operating system especially Linux CentOS 7 has its own command line interface. The command line interface is available with a shell command prompt. A shell in this context is a program presenting a command line interface. Through this shell program, the execution of the command to preview the host name of an operating system is possible.

Using hostname to preview host name of an operating system in Linux CentOS 7

One of the available command is ‘hostname’. Just execute that command in that shell command prompt :

hostname

For an example :

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]#

According to the manual page of the command, it will show or set the system’s host name as follows :

[root@localhost ~]# man hostname

The above command execution will display the following manual page of the command ‘hostname’ :

HOSTNAME(1) Linux Programmer's Manual HOSTNAME(1)

NAME
hostname - show or set the system's host name
...

Using hostnamectl to preview host name of an operating system in Linux CentOS 7

Another command available in the CentOS 7 to preview the host name of the operating system is by using ‘hostnamectl’. The following is the pattern of the command :

hostnamectl

For an example

[root@localhost ~]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1e6e9c9002cd9609bf851a132b8bf805
           Boot ID: 0c3a5b6f181c46a5bd439415d6bfac0b
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.11.1.el7.x86_64
      Architecture: x86-64
[root@localhost ~]#

And by looking at the manual page of the command, the following information will explain the usage the command ‘hostnamectl’. Just type the command below :

[root@localhost ~]# man hostnamectl

The following is the actual output of the above command execution to view the manual page of ‘hostnamectl’ :

HOSTNAMECTL(1)
NAME
       hostnamectl - Control the system hostname

SYNOPSIS
       hostnamectl [OPTIONS...] {COMMAND}
...

One thought on “How to Preview Host Name of an Operating System in Linux CentOS 7

Leave a Reply