Home / Alt manpages / nmtui-hostname(1)

  • nmtui-hostname(1)
  • User command
  • linux

Set and verify a Linux hostname with nmtui-hostname

You will change the system hostname through NetworkManager's text interface, confirm the value from the shell, and know how to restore the previous name if you made a mistake. On this machine, the installed command comes from NetworkManager 1.46.0.

Allow about ten minutes. You need a local or remote terminal, NetworkManager running, and permission to change the system hostname. The interface is interactive, so use a real terminal rather than a command pipeline. Saving the change may trigger a PolicyKit authentication prompt or require an administrator account.

1. Record the current hostname

Before changing anything, save the current value in your notes. This is a read-only check and does not need elevated privileges:

$ nmcli general hostname
old-name.example

The output on your host will differ. You can also inspect the hostname through systemd's hostname tool:

$ hostnamectl status
   Static hostname: old-name.example

Keep the old value visible while you work. A hostname change can affect shell prompts, monitoring, remote access records, certificates, inventory systems and scripts that use the machine name. This guide changes only the hostname. It does not rename network connections, update DNS, change /etc/hosts, or issue new certificates.

Checkpoint

You have written down the current hostname and know which systems, if any, depend on it.

2. Check the installed activity

The manpage describes nmtui-hostname as the standalone form of the nmtui hostname activity. It accepts no hostname argument. Run it from the terminal:

$ command -v nmtui-hostname
/usr/bin/nmtui-hostname
$ nmtui-hostname

Do not add a value after the command. It is a curses-based screen, not a command-line setter. The installed 1.46.0 binary also rejects options such as --version, so use the package query below when you need the package version:

$ dpkg-query -W -f='${Package} ${Version}\n' network-manager
network-manager 1.46.0-1ubuntu2.8

Your distribution's package revision may be different even when the upstream NetworkManager version is the same.

3. Enter the new hostname

When the screen opens, use the hostname field shown by nmtui. Replace the example with the name assigned to this machine:

edge-01.example

Use a name that matches your organisation's naming rules. A fully qualified name such as edge-01.example is often less ambiguous than a short name, but the right choice depends on your DNS and operating policies. Do not paste whitespace, shell punctuation or an untrusted value into the field. If you are unsure whether the name is acceptable, stop at this screen and check with the administrator responsible for DNS and host inventory.

Move to the screen's confirmation control with the arrow or Tab keys, then confirm the change. The exact key hints are displayed by nmtui at the bottom of the screen. If authentication is requested, review the action before entering administrator credentials. A password prompt is a permission boundary, not evidence that the hostname itself has been validated.

Changing a hostname is a system-wide state change. It normally does not interrupt active network connections, but programs can notice the new name immediately. Avoid doing it during an incident or a maintenance window where stable host identity is required.

4. Exit and verify the saved value

After nmtui reports that the change was accepted, leave the interface using its exit control. Back at the shell, ask NetworkManager for the hostname:

$ nmcli general hostname
edge-01.example

Check the system view as well:

$ hostnamectl status
   Static hostname: edge-01.example

Depending on the host's init system and NetworkManager configuration, the status output can contain other hostname fields. The useful check here is that the static or system hostname now matches the value you entered. You can also run hostname for the kernel's current name:

$ hostname
edge-01.example

If the shell prompt still shows the old name, start a new shell or log in again. A prompt is presentation, not the authoritative verification. Existing SSH sessions can retain their old prompt until they are refreshed.

Checkpoint

nmcli general hostname, hostnamectl status, and, where relevant, hostname agree on the new value.

5. Recover if the name is wrong

Do not edit /etc/hostname by hand while diagnosing a failed nmtui change. That can leave the service view and the file out of step. Reopen the same activity and enter the recorded old value:

$ nmtui-hostname

Confirm the replacement, exit, and verify again:

$ nmcli general hostname
old-name.example

If nmtui cannot save the value, check that NetworkManager is running and that your account is allowed to perform the operation:

$ nmcli general status
$ nmcli general permissions

These commands are read-only. A denied permission needs an administrator or an appropriate PolicyKit rule; repeatedly entering credentials will not fix a policy denial. If NetworkManager is unavailable, do not restart it blindly on a remote machine. Investigate the service state and use your normal change-control procedure, because restarting it can affect managed interfaces.

6. Check the surrounding systems

nmtui-hostname sets the system hostname, but it does not guarantee that other name services know about it. From a host where the name should resolve, test the DNS record separately. Also review /etc/hosts, SSH known-host records, monitoring labels, configuration management inventory and TLS names if they use the old value. Update those systems through their normal management process rather than assuming a local hostname change updates them.

NetworkManager can also learn a hostname from DHCP or reverse DNS according to its configuration. If the name changes back after a reconnect or reboot, investigate hostname management settings and the network's DHCP or DNS behaviour before repeating the nmtui change. The symptom is configuration ownership, not necessarily a faulty text interface.

Done means

  • You recorded the original hostname before opening the interface.
  • You used nmtui-hostname without inventing command-line options or arguments.
  • The new name was accepted with the required authorisation.
  • nmcli general hostname and hostnamectl status show the intended value.
  • You know how to restore the old value through the same screen.
  • DNS, hosts files, monitoring, inventory and certificates have been treated as separate follow-up changes.