hostnamectl(1)
Query and change the system hostname and other host settings.
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
| Flag | What it does |
|---|---|
--static | Show or set the static hostname (the one read from /etc/hostname) |
--transient | Show or set the transient hostname (runtime-only, lost on reboot) |
--pretty | Show or set the pretty hostname (free-form, user-friendly description) |
--chassis | Query or set the chassis type (desktop, laptop, server, etc.) |
--deployment | Query or set the deployment environment (development, production, etc.) |
--icon-name | Query or set the icon name representing the machine type |
-p, --no-pager | Do not pipe output to a pager |
--json= | Output as JSON (short, pretty, or off) |
-H, --host= | Operate on a remote host via SSH |
--help | Display help message and exit |
Examples
Display current hostname configuration including static, transient, and pretty names
hostnamectlShow detailed status of the system hostname and machine metadata
hostnamectl statusChange the static hostname to 'myserver' (writes to /etc/hostname)
sudo hostnamectl set-hostname myserverSet 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 laptopMark the system as operating in a production environment
hostnamectl set-deployment productionDisplay hostname information in formatted JSON output
hostnamectl --json=prettyQuery the hostname of a remote system via SSH
hostnamectl -H [email protected]