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. Common Practices
  6. Best Practices
  7. Example Usage
  8. Conclusion
  9. 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.

What is nmtui?#

nmtui is a text-based user interface for 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.

Installation#

The nmtui utility is usually included in the NetworkManager package. To install NetworkManager and nmtui on a Debian or Ubuntu system, you can use the following command:

sudo apt-get install network-manager

On a Red Hat or CentOS system, you can use the following command:

sudo yum install NetworkManager

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 an existing network connection.
  • Activate a connection: Allows you to activate an existing network connection.
  • Deactivate a connection: Allows you to deactivate an existing network connection.
  • Add a new connection: Allows you to create a new network connection.
  • Set system hostname: Allows you to set the system hostname.
  • 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, press Enter to save the changes.

Adding a New Connection#

To add a new network connection, select the "Add a new connection" option from the main menu. You will be prompted to select the type of connection you want to create, such as a wired or wireless connection. Follow the on-screen instructions to configure the connection settings, such as the SSID, password, and IP address. When you are finished, press Enter to save the new connection.

Activating and Deactivating Connections#

To activate an existing network connection, select the "Activate 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 activate and press Enter. To deactivate a connection, select the "Deactivate a connection" option from the main menu and follow the same procedure.

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 encryption to protect your network from unauthorized access.

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 "Add a new connection" option from the main menu.
  2. Select the "Wi-Fi" option from the list of connection types.
  3. Enter the SSID (name) of the wireless network you want to connect to.
  4. Select the security type (e.g., WPA2-PSK) and enter the password.
  5. Configure the IP settings (e.g., DHCP or static IP).
  6. Press Enter to save the new connection.
  7. Select the "Activate a connection" option from the main menu and select 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. 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#