{"id":7325,"date":"2026-02-19T07:30:08","date_gmt":"2026-02-19T07:30:08","guid":{"rendered":"https:\/\/commandlinux.com\/?p=7325"},"modified":"2026-05-12T12:20:56","modified_gmt":"2026-05-12T12:20:56","slug":"hostnamectl","status":"publish","type":"post","link":"https:\/\/commandlinux.com\/man-page\/hostnamectl\/","title":{"rendered":"HOSTNAMECTL"},"content":{"rendered":"\n<link rel=\"stylesheet\" href=\"https:\/\/wordpress-541078-6199923.cloudwaysapps.com\/wp-content\/themes\/smart-mag\/man-style.css\"><script>document.title = \"HOSTNAMECTL linux command man page\";<\/script><div class='man-page' style='max-width:900px;margin:40px auto;'>\n\n<A NAME=\"lbAB\">&nbsp;<\/A>\n<H2>NAME<\/H2>\n\nhostnamectl &#8211; Control the system hostname\n<A NAME=\"lbAC\">&nbsp;<\/A>\n<H2>SYNOPSIS<\/H2>\n\n<DL COMPACT>\n<DT>\n<B>hostnamectl<\/B> [OPTIONS&#8230;] {COMMAND}\n<\/DL>\n<A NAME=\"lbAD\">&nbsp;<\/A>\n<H2>DESCRIPTION<\/H2>\n\n<P>\n\n<B>hostnamectl<\/B>\n<DD>may be used to query and change the system hostname and related settings.\n<P>\n\nThis tool distinguishes three different hostnames: the high-level &quot;pretty&quot; hostname which might include all kinds of special characters (e.g. &quot;Lennart&#8217;s Laptop&quot;), the static hostname which is used to initialize the kernel hostname at boot (e.g. &quot;lennarts-laptop&quot;), and the transient hostname which is a default received from network configuration. If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used.\n<P>\n\nNote that the pretty hostname has little restrictions on the characters used, while the static and transient hostnames are limited to the usually accepted characters of Internet domain names.\n<P>\n\nThe static hostname is stored in\n\/etc\/hostname, see\n<B><A HREF=\"\/man-page\/man5\/hostname\/\">hostname<\/A><\/B>(5)\nfor more information. The pretty hostname, chassis type, and icon name are stored in\n\/etc\/machine-info, see\n<B><A HREF=\"\/man-page\/man5\/machine-id\/\">machine-id<\/A><\/B>(5).\n<A NAME=\"lbAE\">&nbsp;<\/A>\n<H2>OPTIONS<\/H2>\n\n<P>\n\nThe following options are understood:\n<P>\n\n<B>&#8211;no-ask-password<\/B>\n<DL COMPACT><DT><DD>\nDo not query the user for authentication for privileged operations.\n<\/DL>\n\n<P>\n\n<B>&#8211;static<\/B>, <B>&#8211;transient<\/B>, <B>&#8211;pretty<\/B>\n<DL COMPACT><DT><DD>\nIf\n<B>status<\/B>\nis used (or no explicit command is given) and one of those fields is given,\n<B>hostnamectl<\/B>\nwill print out just this selected hostname.\n<P>\nIf used with\n<B>set-hostname<\/B>, only the selected hostname(s) will be updated. When more than one of those options is used, all the specified hostnames will be updated.\n<\/DL>\n\n<P>\n\n<B>-H<\/B>, <B>&#8211;host=<\/B>\n<DL COMPACT><DT><DD>\nExecute the operation remotely. Specify a hostname, or a username and hostname separated by\n&quot;@&quot;, to connect to. The hostname may optionally be suffixed by a container name, separated by\n&quot;:&quot;, 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 with\n<B>machinectl -H <\/B><B><\/B><I>HOST<\/I>.\n<\/DL>\n\n<P>\n\n<B>-h<\/B>, <B>&#8211;help<\/B>\n<DL COMPACT><DT><DD>\nPrint a short help text and exit.\n<\/DL>\n\n<P>\n\n<B>&#8211;version<\/B>\n<DL COMPACT><DT><DD>\nPrint a short version string and exit.\n<\/DL>\n\n<P>\n\nThe following commands are understood:\n<P>\n\n<B>status<\/B>\n<DL COMPACT><DT><DD>\nShow current system hostname and related information.\n<\/DL>\n\n<P>\n\n<B>set-hostname <\/B><B><\/B><I>NAME<\/I>\n<DL COMPACT><DT><DD>\nSet the system hostname to\n<I>NAME<\/I>. By default, this will alter the pretty, the static, and the transient hostname alike; however, if one or more of\n<B>&#8211;static<\/B>,\n<B>&#8211;transient<\/B>,\n<B>&#8211;pretty<\/B>\nare used, only the selected hostnames are changed. If the pretty hostname is being set, and static or transient are being set as well, the specified hostname will be simplified in regards to the character set used before the latter are updated. This is done by replacing spaces with\n&quot;-&quot;\nand removing special characters. This ensures that the pretty and the static hostname are always closely related while still following the validity rules of the specific name. This simplification of the hostname string is not done if only the transient and\/or static host names are set, and the pretty host name is left untouched.\n<P>\nPass the empty string\n&quot;&quot;\nas the hostname to reset the selected hostnames to their default (usually\n&quot;localhost&quot;).\n<\/DL>\n\n<P>\n\n<B>set-icon-name <\/B><B><\/B><I>NAME<\/I>\n<DL COMPACT><DT><DD>\nSet the system icon name to\n<I>NAME<\/I>. The icon name is used by some graphical applications to visualize this host. The icon name should follow the\nm[blue]<B>Icon Naming Specification<\/B>m[]<FONT SIZE=\"-2\">[1]<\/FONT>.\n<P>\nPass an empty string to reset the icon name to the default value, which is determined from chassis type (see below) and possibly other parameters.\n<\/DL>\n\n<P>\n\n<B>set-chassis <\/B><B><\/B><I>TYPE<\/I>\n<DL COMPACT><DT><DD>\nSet the chassis type to\n<I>TYPE<\/I>. The chassis type is used by some graphical applications to visualize the host or alter user interaction. Currently, the following chassis types are defined:\n&quot;desktop&quot;,\n&quot;laptop&quot;,\n&quot;server&quot;,\n&quot;tablet&quot;,\n&quot;handset&quot;,\n&quot;watch&quot;, as well as the special chassis types\n&quot;vm&quot;\nand\n&quot;container&quot;\nfor virtualized systems that lack an immediate physical chassis.\n<P>\nPass an empty string to reset the chassis type to the default value which is determined from the firmware and possibly other parameters.\n<\/DL>\n\n<A NAME=\"lbAF\">&nbsp;<\/A>\n<H2>EXIT STATUS<\/H2>\n\n<P>\n\nOn success, 0 is returned, a non-zero failure code otherwise.\n<A NAME=\"lbAG\">&nbsp;<\/A>\n\n<H2>NOTES<\/H2>\n\n<DL COMPACT>\n<DT> 1.<DD>\nIcon Naming Specification\n<DL COMPACT><DT><DD>\nhttp:\/\/standards.freedesktop.org\/icon-naming-spec\/icon-naming-spec-latest.html<\/A>\n<\/DL>\n\n<P>\n<\/DL>\n","protected":false},"excerpt":{"rendered":"<p>Control the system hostname<\/p>\n","protected":false},"author":1,"featured_media":7348,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"class_list":["post-7325","post","type-post","status-publish","format-standard","has-post-thumbnail","category-man-page"],"_links":{"self":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/7325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/comments?post=7325"}],"version-history":[{"count":2,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/7325\/revisions"}],"predecessor-version":[{"id":10964,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/7325\/revisions\/10964"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/media\/7348"}],"wp:attachment":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/media?parent=7325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/categories?post=7325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/tags?post=7325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}