$linuxjunkies
>

hostnamectl(1)

Query and change the system hostname and other host settings.

UbuntuDebianFedoraArch

Synopsis

hostnamectl [OPTIONS...] {COMMAND}

Description

hostnamectl is a systemd utility that controls the system hostname and related machine metadata. It allows you to view and modify the hostname, machine ID, chassis type, deployment environment, and other host identification settings.

The command works with systemd's hostname service and stores settings in system configuration files like /etc/hostname and /etc/machine-info. Changes typically take effect immediately without requiring a reboot.

Common options

FlagWhat it does
--staticShow or set the static hostname (the one read from /etc/hostname)
--transientShow or set the transient hostname (runtime-only, lost on reboot)
--prettyShow or set the pretty hostname (free-form, user-friendly description)
--chassisQuery or set the chassis type (desktop, laptop, server, etc.)
--deploymentQuery or set the deployment environment (development, production, etc.)
--icon-nameQuery or set the icon name representing the machine type
-p, --no-pagerDo not pipe output to a pager
--json=Output as JSON (short, pretty, or off)
-H, --host=Operate on a remote host via SSH
--helpDisplay help message and exit

Examples

Display current hostname configuration including static, transient, and pretty names

hostnamectl

Show detailed status of the system hostname and machine metadata

hostnamectl status

Change the static hostname to 'myserver' (writes to /etc/hostname)

sudo hostnamectl set-hostname myserver

Set a friendly, human-readable hostname description

sudo hostnamectl set-hostname --pretty 'My Development Workstation'

Set the chassis type to laptop (affects system behavior and icons)

sudo hostnamectl set-chassis laptop

Mark the system as operating in a production environment

hostnamectl set-deployment production

Display hostname information in formatted JSON output

hostnamectl --json=pretty

Query the hostname of a remote system via SSH

hostnamectl -H [email protected]

Related commands