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
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 can 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
Use the nmtui-connect command to access the sub-screen of the second option.
#nmtui-connect
To access the sub-screen of the third option, use the nmtui-hostname command.
#nmtui-hostname
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 option-related settings.
Let’s take a simple 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.
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.
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 Ethernet and use the tab key to select Create. After selecting the Create option, press the Enter key.
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.
To navigate between the options, use the Tab key. Use Enter key to show sub-options of the selected option. Use the Space key to toggle the status of check boxes.
After updating all settings, select OK, and press Enter key.
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 Enter key.
On the first screen, select the second option Activate a connection, select OK, and hit the Enter key.
Select the recently added connection, move to Activate option and press Enter key, move to the Back option, and Press Enter key.
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.
Change the hostname, select OK, and press Enter key.
Press the Enter key to confirm the change. On the first screen, select the Quit option and press the Enter key.
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.
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.
To verify the hostname, we can use the hostname command.
To delete the created connection, open the nmtui utility again, select Edit a connection, and press Enter key.
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.
Quit from the nmtui utility.
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.
That's all for this tutorial. In this tutorial, we learned how to use the nmtui utility to manage network connections.