nmtui ‐ #networking - five4nets/Linux-Knowledgebase GitHub Wiki
nmtui
Command in Linux
Tutorial: Using the 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.
nmtui
Installing NetworkManager and 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
nmtui
Launching 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.
nmtui
Features and Commands
Key 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 tonmtui
).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
nmtui
Examples of Using Example 1: Configuring a Wi-Fi Connection
- Run
nmtui
:nmtui
- Select Edit a connection and press Enter.
- Choose Add to create a new connection.
- Select Wi-Fi as the connection type.
- 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.
- Profile name: Enter a name (e.g.,
- Select OK to save.
- 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
- Launch
nmtui
. - Select Edit a connection.
- Select an existing Ethernet connection or Add a new one.
- 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
).
- Profile name: E.g.,
- Save with OK.
- Activate the connection via Activate a connection.
Verification:
ip addr show
Example 3: Changing the System Hostname
- Run
nmtui
. - Select Set system hostname.
- Enter a new hostname (e.g.,
my-server
). - Select OK to apply.
Verification:
hostnamectl
Example 4: Deleting a Connection
- Open
nmtui
and select Edit a connection. - Highlight the connection to delete.
- 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
orip
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.