The nmtui Command and Utility on Linux

This tutorial explains what the nmtui utility is. Learn how to use the nmtui utility on Linux to add new connections and manage existing connections.

A network device is an Ethernet card that connects the system to the network. A connection is a collection of all settings. There are many tools and utilities that you can use to manage network devices and connections. The nmtui utility is one of them.

The nmtui utility provides a curses-based application for managing network devices and connections. The following command starts this utility.

#nmtui

nmtui command

On the first screen, it has the following three options.

Edit a connection: - This option allows us to add a new connection and manage existing connections.

Activate a connection: - This option allows us to activate or deactivate a connection on an interface.

Set system hostname: - This option allows us to change or set the system hostname.

To move between the options, we use the Tab key or arrow keys. Each option has a sub-screen that allows us to configure the option. To access the sub-screen of the option, select the option and press Enter key.

The nmtui utility also provides a command to directly access the sub-screen of each option.

To access the sub-screen of the first option, use the nmtui-edit command.

#nmtui-edit

nmtui-edit command

Use the nmtui-connect command to access the sub-screen of the second option.

#nmtui-connect

nmtui connect

To access the sub-screen of the third option, use the nmtui-hostname command.

#nmtui-hostname

nmtui host name command

No matter, whether you use the first screen of the nmtui utility or the related command to access the sub-screen of an option, the settings available on the sub-screen are the same. The above-mentioned commands are only used to bypass the first screen of the nmtui command. From the sub-screen of an option, we can manage all settings related to the option.

Let’s take an example to understand how to use each option and its settings. In this example, we will perform the following activities.

  • Create a new connection
  • Activate the connection
  • Change the hostname
  • Verify the changes
  • Delete the created connection

The nmtui command examples

Select the first option (Edit a connection) on the first screen and press the Enter key.

edit a connection

The next screen displays the existing connection on the left side. On the right side, it displays options to manage them. To add a new connection, select the Add option from the right side, and press the Enter key.

add a new connection

On the next screen, we have to select the network interface for which we are creating this connection. The list includes many types of network interfaces. You can create a connection for any network interface. But you can use that connection only if that interface exists on the system. For example, suppose you created a connection for an Ethernet interface. You can use this connection only if the system has an Ethernet card.

Select the Ethernet and use the tab key to select the Create option. After selecting the Create option, press the Enter key.

type of interface

The next screen allows us to customize the connection.

Set profile name to CustomCon1, IPv4 Configuration to Manual, IPv4 address to 10.0.0.10/8, and Automatically connect to No.

default edit screen

To navigate between the options, use the Tab key. Use the Enter key to show sub-options of the selected option. Use the Space key to toggle the state of checkboxes.

After updating all settings, select the OK button, and press the Enter key.

new connection settings

The nmtui utility creates a new connection with specified settings and adds it to the list of connections. By default, it does not activate the new connection.

To activate the new connection, select Back and press the Enter key.

new connection added

On the first screen, select the second option Activate a connection, select OK, and hit the Enter key.

activate a connection option

Select the recently added connection, move to the Activate option and press the Enter key, move to the Back option, and Press the Enter key.

activate a connection

So far, we have added a new connection and have made the new connection active. Now, let's change the hostname. To change the hostname, select the 'set system hostname' option, move to OK, and press the Enter key.

set a hostname option

Change the hostname, select OK, and press the Enter key.

change hostname

Press the Enter key to confirm the change. On the first screen, select the Quit option and press the Enter key.

apply change

To verify the changes, we can use the ip addr show [interface name] command. This command displays the current IP configuration of the specified device.

ip addr show command

To view the connections, we can use the nmcli con show command. This command lists all connections. If a connection is active on an interface, the interface's name will be displayed in the device section of the output.

nmcli con show

To verify the hostname, we can use the hostname command.

hostname command

To delete the created connection, open the nmtui utility again, select the Edit a connection option, and press the Enter key.

edit a connection

Select the connection you want to delete, move to the Delete option, press the Enter key, Select the Delete option, and press the Enter key to confirm the delete operation.

delete a connection

Quit from the nmtui utility.

quit from nmtui

Key points

  • The nmtui utility is part of the NetworkManager package.
  • The NetworkManager provides the default network service on Linux.
  • The NetworkManager provides three tools to manage network devices and connections. These tools are the nmcli, nmtui, and nm-connection-editor.
  • The nmtui utility provides a curses-based application to manage connections. It does not need a GUI environment to run. You can run it on CLI.

ComputerNetworkingNotes Linux Tutorials The nmtui Command and Utility on Linux