HOSTNAMECTL(1)
๐ HOSTNAMECTL(1) โ the hostnamectl girlies' guide ๐
okay so bestie, this is the manual page for hostnamectl from the systemd crew, and it's literally the tool that lets you control your system hostname. she's been around since 195 and she's still serving. let's get into it ๐ซถ
โจ NAME โจ
hostnamectl โ control the system hostname. that's it, that's the whole vibe. ๐
โจ SYNOPSIS โจ
hostnamectl [OPTIONS...] {COMMAND}
โจ DESCRIPTION โจ
so hostnamectl is what you use to query and change your system hostname and all the related lil settings around it. no cap. ๐ธ
systemd-hostnamed.service(8) and this tool both recognise three different hostnames, and honestly the distinction is iconic once you get it:
- the high-level "pretty" hostname โ this one can have all kinds of special characters in it, like
"Lennart's Laptop"๐ - the "static" hostname โ the user-configured one, like
"lennarts-laptop" - the transient hostname โ a fallback value that comes in from network configuration, like
"node12345678"
if a static hostname is set to a valid value, then the transient hostname justโฆ doesn't get used. sorry transient, not your moment. ๐ญ
ngl the pretty hostname has very few restrictions on characters and length โ she's free, she's unbothered. but the static and transient ones are limited to the usually-accepted characters of Internet domain names, and 64 characters maximum (that last bit is a Linux limitation, not a vibe choice).
โจ btw if you need to initialize the system hostname for mounted (but not booted) system images, use systemd-firstboot(1). different tool, different job, iykyk.
โจ COMMANDS โจ
these are the commands, and yes we're going through all of them, no skipping ๐
statusโ shows the system hostname and related info. and honestly? if you don't specify any command, this is the implied default. she's the main character. also: added in version 195.hostname [NAME]โ if you give no argument, it prints the system hostname. if you do pass the optional argument NAME, the command changes the system hostname to NAME. by default this alters the pretty, the static, and the transient hostname all at once โ they all get the glow-up. BUT if you use one or more of--static,--transient,--pretty, then only the selected hostnames get changed. picky, but valid. ๐
and here's the cute part: if the pretty hostname is being set, and static or transient are being set as well, the specified hostname gets simplified in regards to the character set used before the latter are updated. this happens by removing special characters and spaces. the goal is that the pretty and the static hostname stay closely related while still following the validity rules of the specific name. this simplification does not happen if only the transient and/or static hostnames are set and the pretty hostname is left untouched.
the static and transient hostnames must each be either a single DNS label (a string made of 7-bit ASCII lower-case characters, no spaces, no dots, limited to the format allowed for DNS domain name labels), or a sequence of such labels separated by single dots that forms a valid DNS FQDN. the hostname must be at most 64 characters, which is a Linux limitation (DNS allows longer names, but that's not our problem rn).
and omg โ if the question mark character "?" appears in the hostname, it gets automatically substituted by a hexadecimal character derived from the machine-id(5) when applied, securely and deterministically by cryptographic hashing. example: "foobar-????-????" will automatically expand to "foobar-92a9-061c" or similar, depending on the local machine ID. literally magic. ๐ฅ
added in version 249
icon-name [NAME]โ no argument? prints the icon name of the system. optional argument NAME? changes the icon name to NAME. some graphical applications use the icon name to visualize this host. the icon name should follow the Icon Naming Specification[1]. added in version 249 ๐chassis [TYPE]โ no argument = prints the chassis type. pass TYPE and it changes the chassis type to TYPE. graphical apps use it to visualize the host or alter user interaction. currently the defined chassis types are:"desktop","laptop","convertible","server","tablet","handset","watch","embedded", plus the special ones"vm"and"container"for virtualized systems that lack an immediate physical chassis. added in version 249 ๐ฆdeployment [ENVIRONMENT]โ no argument = prints the deployment environment. pass ENVIRONMENT and it changes the deployment environment to ENVIRONMENT. the argument must be a single word without any control characters. one of the following is suggested:"development","integration","staging","production". added in version 249 โญlocation [LOCATION]โ no argument = prints the location string for the system. pass LOCATION and it changes the location string to LOCATION. this should be a human-friendly, free-form string describing the physical location of the system, if it's known and applicable. it can be as generic as"Berlin, Germany"or as specific as"Left Rack, 2nd Shelf". added in version 249 ๐tags [TAG...]โ okay this one is a whole saga so buckle up bestie:- no argument โ prints the machine tags currently configured, as a colon-separated list.
- one or more TAG arguments โ the command replaces the configured tags with the ones you specified. each argument may itself be a colon-separated list of tags, so you can specify them as multiple arguments, as a single colon-separated argument, or literally any combination of the two. duplicate tags get removed and the resulting list is sorted before being stored. and to remove all tags, invoke the command with a single empty string argument. bye tags ๐
- alternatively, each argument may be prefixed with
+or-to incrementally update the configured tags rather than replacing them:+adds all of its (colon-separated) tags to the list,-removes them. example:hostnamectl tags +foo:bar -quux:oooadds the tags"foo"and"bar"and removes"quux"and"ooo". the prefix applies to the whole argument, i.e. to every tag listed within it. and no, you may not combine prefixed and unprefixed arguments in a single invocation. pick a lane. ๐ซ
machine tags are short labels that may be used to classify and group machines for management purposes โ for example to identify the role a machine plays in a deployment, the fleet or organizational unit it belongs to, or any other administrator-defined attribute. each individual tag must be 1...255 characters long and consist only of ASCII alphanumeric characters, "-", "." and "=". a tag may optionally be parameterized with a value in the form "key=value", in which case the same key may not be assigned more than one distinct value. the tags are stored in the TAGS= field of /etc/machine-info; see machine-info(5) for details. they may also be matched against with the ConditionMachineTag=/AssertMachineTag= unit settings, see systemd.unit(5).
added in version 261 (a fresh one, we love a recent addition ๐)
โจ OPTIONS โจ
the following options are understood, and yes, all of them:
--static,--transient,--prettyโ ifstatusis invoked (or no explicit command is given) and one of these switches is specified,hostnamectlwill print out just this selected hostname. so specific. so focused. ๐ฏ
this selection does not apply to JSON output: with --json=, status always prints the full status object. no filtering allowed, sorry.
if used with hostname, only the selected hostnames will be updated. when more than one of these switches is specified, all the specified hostnames will be updated.
added in version 195
-H,--host=โ execute the operation remotely. specify a hostname, or a username and hostname separated by"@", to connect to. the hostname may optionally be suffixed by a port ssh is listening on, separated by":", and then a container name, separated by"/", which connects directly to a specific container on the specified host. this will use SSH to talk to the remote machine manager instance. container names may be enumerated withmachinectl -H HOST. and psst โ put IPv6 addresses in brackets. ๐ง-M,--machine=โ execute operation on a local container. specify a container name to connect to, optionally prefixed by a user name to connect as and a separating"@"character. if the special string".host"is used in place of the container name, a connection to the local system is made (which is useful to connect to a specific user's user bus:"--user --machine=lennart@.host"). if the"@"syntax is not used, the connection is made as root user. if the"@"syntax is used, either the left hand side or the right hand side may be omitted (but not both) โ in that case the local user name and".host"are implied. ๐ซถ--no-ask-passwordโ do not query the user for authentication for privileged operations. no popups, no prompts, we're just doing it.-h,--helpโ print a short help text and exit. classic.--versionโ print a short version string and exit. also classic.--json=MODEโ shows output formatted as JSON. expects one of:"short"โ for the shortest possible output without any redundant whitespace or line breaks"pretty"โ for a pretty version of the same, with indentation and line breaks"off"โ to turn off JSON output, and this is the default
-jโ equivalent to--json=prettyif running on a terminal, and--json=shortotherwise. she adapts to her environment, we stan an adaptive queen. ๐
โจ EXIT STATUS โจ
on success, 0 is returned. otherwise, a non-zero failure code. simple as that. ๐
โจ SEE ALSO โจ
systemd(1), hostname(1), hostname(5), machine-info(5), systemctl(1), systemd-hostnamed.service(8), systemd-firstboot(1)
โจ NOTES โจ
- Icon Naming Specification https://specifications.freedesktop.org/icon-naming/latest
okay bestie that's the whole page, you ate that, go name your laptop something cute ๐โจ๐
this was hostnamectl from systemd 262.1 โ thanks for reading, ily, mwah ๐ซถ๐๐
๐ฆ where this page comes from
- arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms