Skip to main content
Engineering LibreTexts

08-C.8.2: Managing Linux Services - hostnamectl

  • Page ID
    35225
  • hostnamectl command provides a proper API used to control Linux system hostname and change its related settings. The command also helps to change the hostname without actually locating and editing the /etc/hostname file on a given system.

    Syntax:

    hostnamectl [ OPTIONS ] COMMAND ....

    Where COMMAND can be any of the following:

    • status: Used to check current hostname settings.
    • set-hostname NAME: Used to set system hostname.
    • set-icon-name NAME: Used to set icon name for host.
    • set-chassis NAME: Set chassis type for host.

    Types of hostname:

    • Static: Assigned by system admin and it is used to initialize the kernel hostname during boot time.
    • Dynamic or Transient: Assigned by mDNS server or DHCP server during run time.
    • Pretty: A high-level hostname assigned by system admin or end-user.

    Adapted from:
    "hostnamectl command in Linux with Examples" by Suraj1994, Geeks for Geeks is licensed under CC BY-SA 4.0

    • Was this article helpful?