Linux - Hostname (Kernel, Static)

Linux - Hostname (Kernel, Static)

About

How to manage the hostname under Linux.

For the FQDN, the fully qualified domain name, see How to see and update the Fully Qualified Domain Name (FQDN) on Linux

Management

Set

Static

The static hostname is stored in /etc/hostname.

Historically this file was supposed to only contain the hostname and not the full canonical FQDN. This file is read at boot time by the system initialization scripts to set the hostname.

You can use hostnamectl to change it

hostnamectl set-hostname NAME

Transient ?

What is a Hostname (or System's hostname)?

/etc/sysconfig/network

sysconfig-network

information valid to all network interfaces on the system

HOSTNAME=penguin.example.com

Session - hostname

To set the hostname for a session, use this command

hostname name

See hostname

Get

uname

uname -a hostname

See uname

hostnamectl

hostnamectl
Static hostname: MY-HOSTNAME
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 6ca77495007b44b5b7983fa8f0e34d11
           Boot ID: ccdd558ecf3740d4a84cacba873d2e19
    Virtualization: microsoft
  Operating System: Red Hat Enterprise Linux Server 7.5 (Maipo)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.5:GA:server
            Kernel: Linux 3.10.0-862.14.4.el7.x86_64
      Architecture: x86-64

where:

  • architecture is the architecture of the CPU

hostname

You can query the host name under UNIX or Windows by using the command hostname.

Linux: With the command: Linux - Uname (unix name)





Discover More
Map Of Internet 1973
What is a Hostname (or System's hostname)?

A hostname is a DNS name for a host (ie for the operating system) that is composed of: a label (generally called the short name) and a domain The hostname or computer name: is alogical name for...



Share this page:
Follow us:
Task Runner