nmtui ‐ #networking - five4nets/Linux-Knowledgebase GitHub Wiki

Tutorial: Using the nmtui Command in Linux

nmtui (NetworkManager Text User Interface) is a text-based interface for configuring network settings in Linux systems that use NetworkManager. It provides an intuitive way to manage network connections without editing configuration files manually. This tutorial covers how to use nmtui, including command explanations, examples, and references.

Prerequisites

  • A Linux system with NetworkManager installed (common in distributions like Fedora, Ubuntu, CentOS, etc.).
  • Basic familiarity with terminal navigation.
  • Root or sudo privileges for network configuration.

Installing NetworkManager and nmtui

Before using nmtui, ensure NetworkManager and its TUI tool are installed.

On Debian-based systems (e.g., Ubuntu):

sudo apt update
sudo apt install network-manager

On Red Hat-based systems (e.g., Fedora, CentOS):

sudo dnf install NetworkManager-tui

Verify installation:

nmtui --version

Launching nmtui

To start nmtui, open a terminal and run:

nmtui

This opens a curses-based interface with three main options:

  • Edit a connection: Modify existing network connections or create new ones.
  • Activate a connection: Enable a network connection.
  • Set system hostname: Change the system’s hostname.

Navigate using arrow keys, select with Enter, and exit with Esc or by selecting Quit.

Key nmtui Features and Commands

nmtui interacts with NetworkManager to manage connections. It does not require direct use of additional commands, but understanding related NetworkManager tools can be helpful:

  • nmcli: Command-line interface for NetworkManager (alternative to nmtui).
  • systemctl: Used to manage the NetworkManager service.

Common NetworkManager Service Commands

  • Check NetworkManager status:
    systemctl status NetworkManager
    
  • Start NetworkManager:
    sudo systemctl start NetworkManager
    
  • Enable NetworkManager at boot:
    sudo systemctl enable NetworkManager
    

Examples of Using nmtui

Example 1: Configuring a Wi-Fi Connection

  1. Run nmtui:
    nmtui
    
  2. Select Edit a connection and press Enter.
  3. Choose Add to create a new connection.
  4. Select Wi-Fi as the connection type.
  5. Configure the connection:
    • Profile name: Enter a name (e.g., HomeWiFi).
    • SSID: Enter the Wi-Fi network name (e.g., MyNetwork).
    • Security: Choose the security type (e.g., WPA2).
    • Password: Enter the Wi-Fi password.
  6. Select OK to save.
  7. Go to Activate a connection, select HomeWiFi, and activate it.

Verification:

nmcli connection show
nmcli device status

Example 2: Setting a Static IP for an Ethernet Connection

  1. Launch nmtui.
  2. Select Edit a connection.
  3. Select an existing Ethernet connection or Add a new one.
  4. Configure:
    • Profile name: E.g., OfficeEth.
    • IPv4 Configuration: Change to Manual.
    • Addresses: Add a static IP (e.g., 192.168.1.100/24).
    • Gateway: Set the gateway (e.g., 192.168.1.1).
    • DNS servers: Add DNS (e.g., 8.8.8.8, 8.8.4.4).
  5. Save with OK.
  6. Activate the connection via Activate a connection.

Verification:

ip addr show

Example 3: Changing the System Hostname

  1. Run nmtui.
  2. Select Set system hostname.
  3. Enter a new hostname (e.g., my-server).
  4. Select OK to apply.

Verification:

hostnamectl

Example 4: Deleting a Connection

  1. Open nmtui and select Edit a connection.
  2. Highlight the connection to delete.
  3. Select Delete and confirm.

Verification:

nmcli connection show

Troubleshooting

  • Interface not appearing: Ensure the network device is recognized:
    nmcli device
    
  • Changes not applied: Restart NetworkManager:
    sudo systemctl restart NetworkManager
    
  • Wi-Fi not scanning: Ensure the wireless device is enabled:
    nmcli radio wifi on
    

Best Practices

  • Always verify changes with nmcli or ip commands.
  • Use descriptive profile names for clarity.
  • Back up configuration files (located in /etc/NetworkManager/system-connections/) before major changes.
  • Test connections in a non-production environment first.

References