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 ?

Network - Hostname (System's host name)

/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)





Recommended Pages
Linux - Directory /proc/sys/kernel/

This directory contains configuration files that directly affect the operation of the Kernel acct — Controls the suspension of process accounting based on the percentage of free space available...
Card Puncher Data Processing
Network - Hostname (System's host name)

A hostname is a name for a host (ie for the operating system). The host name or computer name: is alogical name for the host itself is set in the operating system (used to initialize the OS kernel...



Share this page:
Follow us:
Task Runner