1HOSTNAMECTL(1)                    hostnamectl                   HOSTNAMECTL(1)
2
3
4

NAME

6       hostnamectl - Control the system hostname
7

SYNOPSIS

9       hostnamectl [OPTIONS...] {COMMAND}
10

DESCRIPTION

12       hostnamectl may be used to query and change the system hostname and
13       related settings.
14
15       systemd-hostnamed.service(8) and this tool distinguish three different
16       hostnames: the high-level "pretty" hostname which might include all
17       kinds of special characters (e.g. "Lennart's Laptop"), the "static"
18       hostname which is the user-configured hostname (e.g.
19       "lennarts-laptop"), and the transient hostname which is a fallback
20       value received from network configuration (e.g. "node12345678"). If a
21       static hostname is set to a valid value, then the transient hostname is
22       not used.
23
24       Note that the pretty hostname has little restrictions on the characters
25       and length used, while the static and transient hostnames are limited
26       to the usually accepted characters of Internet domain names, and 64
27       characters at maximum (the latter being a Linux limitation).
28
29       Use systemd-firstboot(1) to initialize the system hostname for mounted
30       (but not booted) system images.
31

COMMANDS

33       The following commands are understood:
34
35       status
36           Show system hostname and related information. If no command is
37           specified, this is the implied default.
38
39       hostname [NAME]
40           If no argument is given, print the system hostname. If an optional
41           argument NAME is provided then the command changes the system
42           hostname to NAME. By default, this will alter the pretty, the
43           static, and the transient hostname alike; however, if one or more
44           of --static, --transient, --pretty are used, only the selected
45           hostnames are changed. If the pretty hostname is being set, and
46           static or transient are being set as well, the specified hostname
47           will be simplified in regards to the character set used before the
48           latter are updated. This is done by removing special characters and
49           spaces. This ensures that the pretty and the static hostname are
50           always closely related while still following the validity rules of
51           the specific name. This simplification of the hostname string is
52           not done if only the transient and/or static hostnames are set, and
53           the pretty hostname is left untouched.
54
55           The static and transient hostnames must each be either a single DNS
56           label (a string composed of 7-bit ASCII lower-case characters and
57           no spaces or dots, limited to the format allowed for DNS domain
58           name labels), or a sequence of such labels separated by single dots
59           that forms a valid DNS FQDN. The hostname must be at most 64
60           characters, which is a Linux limitation (DNS allows longer names).
61
62       icon-name [NAME]
63           If no argument is given, print the icon name of the system. If an
64           optional argument NAME is provided then the command changes the
65           icon name to NAME. The icon name is used by some graphical
66           applications to visualize this host. The icon name should follow
67           the Icon Naming Specification[1].
68
69       chassis [TYPE]
70           If no argument is given, print the chassis type. If an optional
71           argument TYPE is provided then the command changes the chassis type
72           to TYPE. The chassis type is used by some graphical applications to
73           visualize the host or alter user interaction. Currently, the
74           following chassis types are defined: "desktop", "laptop",
75           "convertible", "server", "tablet", "handset", "watch", "embedded",
76           as well as the special chassis types "vm" and "container" for
77           virtualized systems that lack an immediate physical chassis.
78
79       deployment [ENVIRONMENT]
80           If no argument is given, print the deployment environment. If an
81           optional argument ENVIRONMENT is provided then the command changes
82           the deployment environment to ENVIRONMENT. Argument ENVIRONMENT
83           must be a single word without any control characters. One of the
84           following is suggested: "development", "integration", "staging",
85           "production".
86
87       location [LOCATION]
88           If no argument is given, print the location string for the system.
89           If an optional argument LOCATION is provided then the command
90           changes the location string for the system to LOCATION. Argument
91           LOCATION should be a human-friendly, free-form string describing
92           the physical location of the system, if it is known and applicable.
93           This may be as generic as "Berlin, Germany" or as specific as "Left
94           Rack, 2nd Shelf".
95

OPTIONS

97       The following options are understood:
98
99       --no-ask-password
100           Do not query the user for authentication for privileged operations.
101
102       --static, --transient, --pretty
103           If status is invoked (or no explicit command is given) and one of
104           these switches is specified, hostnamectl will print out just this
105           selected hostname.
106
107           If used with set-hostname, only the selected hostname(s) will be
108           updated. When more than one of these switches are specified, all
109           the specified hostnames will be updated.
110
111       -H, --host=
112           Execute the operation remotely. Specify a hostname, or a username
113           and hostname separated by "@", to connect to. The hostname may
114           optionally be suffixed by a port ssh is listening on, separated by
115           ":", and then a container name, separated by "/", which connects
116           directly to a specific container on the specified host. This will
117           use SSH to talk to the remote machine manager instance. Container
118           names may be enumerated with machinectl -H HOST. Put IPv6 addresses
119           in brackets.
120
121       -M, --machine=
122           Execute operation on a local container. Specify a container name to
123           connect to, optionally prefixed by a user name to connect as and a
124           separating "@" character. If the special string ".host" is used in
125           place of the container name, a connection to the local system is
126           made (which is useful to connect to a specific user's user bus:
127           "--user --machine=lennart@.host"). If the "@" syntax is not used,
128           the connection is made as root user. If the "@" syntax is used
129           either the left hand side or the right hand side may be omitted
130           (but not both) in which case the local user name and ".host" are
131           implied.
132
133       -h, --help
134           Print a short help text and exit.
135
136       --version
137           Print a short version string and exit.
138
139       --json=MODE
140           Shows output formatted as JSON. Expects one of "short" (for the
141           shortest possible output without any redundant whitespace or line
142           breaks), "pretty" (for a pretty version of the same, with
143           indentation and line breaks) or "off" (to turn off JSON output, the
144           default).
145

EXIT STATUS

147       On success, 0 is returned, a non-zero failure code otherwise.
148

SEE ALSO

150       systemd(1), hostname(1), hostname(5), machine-info(5), systemctl(1),
151       systemd-hostnamed.service(8), systemd-firstboot(1)
152

NOTES

154        1. Icon Naming Specification
155           http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
156
157
158
159systemd 251                                                     HOSTNAMECTL(1)
Impressum