Linux - Hostname

> Operating System - Kernel (Windows, Unix, Linux) > Linux / Unix

1 - About

How to manage the hostname under Linux.

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

Advertising

3 - Management

3.1 - Set

3.1.1 - Permanently - /etc/ conf files

3.1.1.1 - /etc/sysconfig/network

sysconfig-network

information valid to all network interfaces on the system

HOSTNAME=penguin.example.com
3.1.1.2 - /etc/hosts

Information valid by ip

See Linux - Host file (/etc/hosts)

3.1.1.3 - /etc/hostname

The /etc/hostname value is a permanent change.

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.

3.1.2 - Session - hostname

To set the hostname for a session, use this command

hostname name

See hostname

Advertising

3.2 - Get

3.2.1 - uname

uname -a hostname

See uname

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

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)

os/linux/hostname.txt · Last modified: 2019/06/13 15:29 by gerardnico