Configure and Recover Network Connections with nmtui
You will use nmtui to edit an existing NetworkManager connection, activate or deactivate it, and change the system hostname when that is genuinely required. The examples match NetworkManager 1.46.0, supplied here by the network-manager package. Allow about fifteen minutes for a connection change, plus time to test the result.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need a terminal with a usable text interface and NetworkManager running. Most inspection and selection can be started as your ordinary user. Saving a connection or changing the hostname can trigger an authentication prompt, depending on the machine's policy. Have an administrator available when you expect that prompt.
1. Check the installed command
Confirm which executable will run and record the installed package version. These are read-only checks and do not need sudo:
$ command -v nmtui
/usr/bin/nmtui
$ dpkg-query -W -f='${Package} ${Version}\n' network-manager
network-manager 1.46.0-1ubuntu2.8
$ nmtui --help
Usage:
nmtui [OPTION...]
The manpage describes three activities: edit for connection profiles, connect for activation and deactivation, and hostname for the system hostname. Running plain nmtui opens an activity chooser.
Checkpoint
If command -v finds nothing, stop and install or repair NetworkManager through your normal package-management process. Do not copy a different nmtui binary into /usr/bin.
2. Open the connection editor
Start with a profile name that already exists. Replace the placeholder with the exact connection name shown by NetworkManager:
$ nmtui edit 'CONNECTION_NAME'
The edit activity accepts a connection name or ID. If you do not know either, run plain nmtui, choose the edit activity, and select a profile from the list. The editor can add, modify, view and delete profiles, so read the selected name carefully before confirming.
Use the terminal's normal cursor keys and its on-screen controls to move between fields. Do not treat a highlighted field as a saved change: follow the interface to save explicitly, or leave without saving if you were only inspecting it.
Safety boundary
Changing IPv4 addresses, routes, DNS servers, Wi-Fi credentials or connection autoconnect behaviour can interrupt the current session. Save such a change only when you have console access, a second management path, or a documented recovery plan.
3. Make one small change and verify it
Change one setting at a time. For example, if the goal is to correct a connection's DNS configuration, select the existing profile, alter only its DNS field, then save it through the editor. The exact fields available depend on the connection type and the installed NetworkManager build.
After saving, return to the activity chooser or exit nmtui. Verify the connection using NetworkManager's command-line client:
$ nmcli connection show 'CONNECTION_NAME'
$ nmcli device status
The first command should identify the profile. The second shows whether a device is connected. Output varies with the machine, so check the connection name and device state rather than expecting a fixed table.
If the change broke connectivity, reopen the same profile and restore the previous value. If you wrote down the old address, route or DNS values before editing, recovery is a direct reversal. Otherwise use the editor's current values and your network's known-good configuration as the reference. Do not delete the profile as a first response.
4. Activate or deactivate a profile
Use the connect activity when the profile already exists and the immediate task is to bring it up or down:
$ nmtui connect 'CONNECTION_NAME'
The argument may be a connection name, UUID, device name or Wi-Fi SSID. For an interactive list, omit the argument:
$ nmtui connect
Select the intended profile or network, then confirm the action shown by the interface. Activation can replace the route used by your terminal, and deactivation can disconnect the machine. Do not deactivate the only management connection on a remote host unless you have out-of-band access.
Check the result after leaving the interface:
$ nmcli device status
$ nmcli connection show --active
If activation fails, check that the device is present, the SSID or profile name is exact, and any required credentials are available. A privilege prompt is an authorisation decision, not a request to paste a password into the connection name.
5. Change the hostname deliberately
The hostname activity changes the system hostname, not a NetworkManager connection profile:
$ nmtui hostname
Record the existing value before saving. You can inspect it without changing state:
$ hostnamectl hostname
Enter the new hostname only if you understand how local naming, certificates, monitoring and remote access use it. Saving may require elevated authorisation. After saving, verify:
$ hostnamectl hostname
new-hostname.example.test
To recover, run nmtui hostname again and restore the value you recorded. Do not assume that changing the hostname also updates DNS, certificate names or every application configuration.
6. Avoid the common traps
- Plain
nmtuiopens a chooser;nmtui edit,nmtui connectandnmtui hostnameselect an activity directly. editandconnecttake different identifiers. An SSID is valid forconnect; the documentededitform uses a connection name or ID.- A successful save means NetworkManager accepted the profile change. It does not prove that the device can reach the intended gateway or DNS service.
- Do not add
sudoautomatically. Use elevation only when the system asks for authorisation, and inspect the action before approving it. - Do not delete a profile to undo a failed activation. Restore the previous value or select another known-good profile.
Done means
- You confirmed the installed
nmtuiand NetworkManager version. - You selected the intended activity and profile before confirming a change.
- You verified the resulting device or active-connection state with
nmcli. - You kept a recovery path before changing a route, address, DNS setting or remote host connection.
- Any hostname change was recorded and can be reversed from
nmtui hostname.