nmtui - A Text Interface for Configuring Networking with NetworkManager

In the world of Linux system administration, configuring networking can sometimes be a complex task, especially when dealing with graphical interfaces that may not be available in all environments. This is where nmtui comes to the rescue. nmtui is a text-based user interface (TUI) that allows users to configure networking easily by controlling NetworkManager, a powerful network management service in Linux. This blog post will provide a detailed overview of nmtui, including its features, common practices, best practices, and example usage.

Table of Contents#

  1. What is NetworkManager?
  2. What is nmtui?
  3. Installation
  4. Using nmtui
  5. Configuring a Static IP Address
  6. nmtui vs nmcli
  7. Common Practices
  8. Best Practices
  9. Example Usage
  10. Conclusion
  11. References

What is NetworkManager?#

NetworkManager is a system service that manages network devices and connections in Linux. It provides a unified way to configure and manage network interfaces, including wired, wireless, and VPN connections. NetworkManager supports various network technologies and protocols, such as DHCP, static IP, and Wi-Fi. It also provides a graphical user interface (GUI) and a command-line interface (CLI) for network configuration. The latest stable release is NetworkManager 1.56, which continues to be the standard network configuration tool across most major Linux distributions.

What is nmtui?#

nmtui (NetworkManager Text User Interface) is a curses-based TUI application for interacting with NetworkManager. It allows users to configure network connections using a simple and intuitive menu-driven interface. nmtui is particularly useful in environments where a graphical interface is not available, such as in remote terminals or on servers. With nmtui, users can easily create, edit, activate, and deactivate network connections without having to use complex command-line tools.

nmtui also provides shortcut binaries for direct access to specific functions:

  • nmtui-edit — Opens the connection editor directly
  • nmtui-connect — Opens the connection list for activating or deactivating connections
  • nmtui-hostname — Opens the hostname editor directly

Installation#

The nmtui utility is included in the NetworkManager TUI package. On most systems, NetworkManager is installed by default, but the TUI component may need to be installed separately.

On a Debian or Ubuntu system:

sudo apt install network-manager

On a Fedora, RHEL, or CentOS system:

sudo dnf install NetworkManager-tui

After installation, verify that nmtui is available:

which nmtui

Using nmtui#

Launching nmtui#

To launch nmtui, simply open a terminal and run the following command:

sudo nmtui

You may need to enter your password to run the command with administrative privileges.

When you launch nmtui, you will see the main menu with the following options:

  • Edit a connection: Allows you to edit, add, or delete network connections.
  • Activate a connection: Allows you to activate or deactivate an existing network connection.
  • Set system hostname: Allows you to set the system hostname.
  • Radio: Allows you to toggle wireless interfaces (Wi-Fi and WWAN) on or off.
  • Quit: Exits the nmtui utility.

Editing a Connection#

To edit an existing network connection, select the "Edit a connection" option from the main menu. You will see a list of available connections. Use the arrow keys to select the connection you want to edit and press Enter. You can then modify the connection settings, such as the IP address, subnet mask, gateway, and DNS servers. When you are finished, select "OK" to save the changes.

Adding a New Connection#

To add a new network connection, select the "Edit a connection" option from the main menu, then choose "Add" at the top of the connections list. You will be prompted to select the type of connection you want to create, such as Ethernet, Wi-Fi, Bond, Bridge, or VLAN. Follow the on-screen instructions to configure the connection settings. When you are finished, select "OK" to save the new connection.

Activating and Deactivating Connections#

To activate or deactivate a network connection, select the "Activate a connection" option from the main menu. You will see a list of available connections with their current status. Use the arrow keys to select the connection and press Enter to toggle its state. An asterisk (*) indicates an active connection.

Alternatively, you can activate or deactivate connections from the command line after configuring them with nmtui:

nmcli connection up "Connection Name"
nmcli connection down "Connection Name"

Setting the System Hostname#

From the main menu, select "Set system hostname" to change the system hostname. Enter the new hostname and press Enter. The change takes effect immediately without requiring a restart. Verify the change with:

hostname

Configuring a Static IP Address#

One of the most common uses of nmtui is configuring a static IP address. Here is how to set a static IPv4 address:

  1. Launch nmtui and select Edit a connection
  2. Choose your network interface and select Edit
  3. Under IPv4 CONFIGURATION, change <Automatic> to <Manual>
  4. Fill in the network details:
    • Addresses: 192.168.1.100/24 (IP address with CIDR notation)
    • Gateway: 192.168.1.1
    • DNS servers: 8.8.8.8, 1.1.1.1
    • Search domains: example.com (optional)
  5. Select OK to save

After saving, restart NetworkManager to apply the changes:

sudo systemctl restart NetworkManager

Verify the configuration:

ip -4 addr show
ip route show

nmtui vs nmcli#

Both nmtui and nmcli are NetworkManager tools, but they serve different use cases:

Featurenmtuinmcli
InterfaceInteractive menu-driven TUICommand-line arguments
Best forManual configuration, beginnersScripting, automation, advanced users
Learning curveLowModerate
ScriptabilityNoYes
Remote serversExcellentExcellent

Use nmtui when you want a visual, guided experience. Use nmcli when you need to script network changes or automate configurations across multiple systems.

Common Practices#

  • Backup your network configuration: Before making any changes to your network configuration, it is a good practice to backup your existing configuration. You can do this by copying the /etc/NetworkManager/system-connections directory to a safe location.
  • Test your network connection: After making changes to your network configuration, it is important to test your network connection to ensure that it is working properly. You can use the ping command to test connectivity to other hosts on the network.
  • Use descriptive names for your connections: When creating or editing network connections, use descriptive names that clearly identify the purpose of the connection. This will make it easier to manage your network connections in the future.

Best Practices#

  • Keep NetworkManager up to date: Regularly update NetworkManager to the latest version to ensure that you have the latest security patches and bug fixes.
  • Use static IP addresses for servers: If you are configuring a server, it is recommended to use a static IP address to ensure that the server can be easily reached by other hosts on the network.
  • Secure your wireless connections: When configuring wireless connections, use strong passwords and WPA2 or WPA3 encryption to protect your network from unauthorized access.
  • Restart NetworkManager after changes: After making changes with nmtui, restart the NetworkManager service to ensure all changes take effect properly.

Example Usage#

Let's say you want to create a new wireless connection using nmtui. Here are the steps:

  1. Launch nmtui by running the following command:
sudo nmtui
  1. Select the "Edit a connection" option from the main menu.
  2. Select "Add" to create a new connection.
  3. Select the "Wi-Fi" option from the list of connection types.
  4. Enter the SSID (name) of the wireless network you want to connect to.
  5. Select the security type (e.g., WPA2-PSK or WPA3) and enter the password.
  6. Configure the IP settings (e.g., DHCP or static IP).
  7. Select "OK" to save the new connection.
  8. Return to the main menu, select "Activate a connection", and choose the new wireless connection to activate it.

Conclusion#

nmtui is a powerful and user-friendly tool for configuring networking in Linux. It provides a simple and intuitive text-based interface that allows users to easily manage network connections without having to use complex command-line tools. Whether you are a system administrator managing servers or a desktop user configuring your home network, nmtui offers an accessible way to handle NetworkManager configurations. By following the common practices and best practices outlined in this blog post, you can ensure that your network configuration is secure and reliable.

References#