Linux - Hostname (Kernel, Static)

1 - About

How to manage the hostname under Linux.

For the FQDN, the fully qualified domain name, see Linux - Fully Qualified Domain Name (FQDN)

3 - Management

3.1 - Set

3.1.1 - 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

3.1.2 - Transient ? - /etc/sysconfig/network


information valid to all network interfaces on the system

3.1.3 - Session - hostname

To set the hostname for a session, use this command

hostname name

See hostname

3.2 - Get

3.2.1 - uname

uname -a hostname

See uname

3.2.2 - 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


  • architecture is the architecture of the CPU

3.2.3 - hostname

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

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

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap