How to use the command 'nmtui' (with examples)
- Linux
- December 25, 2023
The ’nmtui’ command is a text user interface for controlling NetworkManager. It provides an interactive way to manage network connections and settings. The command can be used to open the user interface, view and manage available connections, connect to a specific network, edit/add/delete a network, and set the system hostname.
Use case 1: Open the user interface
Code:
nmtui
Motivation: Using this command opens the NetworkManager TUI, allowing users to interactively manage network connections and settings. This can be useful when a graphical user interface is not available, for example, in a remote server environment.
Explanation: The ’nmtui’ command is used to open the NetworkManager TUI.
Example output:
Text user interface for controlling NetworkManager.
Use arrow keys to navigate, enter to select an option.
More information: <https://networkmanager.dev/docs/api/latest/nmtui.html>.
Use case 2: Show a list of available connections, with the option to activate or deactivate them
Code:
nmtui connect
Motivation: This command provides a convenient way to view a list of available network connections and manage them. It allows users to activate or deactivate connections as needed.
Explanation: The ’nmtui connect’ command is used to display a list of available network connections. The user can then select a connection and choose to activate or deactivate it.
Example output:
Available connections:
* Wired connection 1
Wireless connection 1
VPN connection 1
[Edit a connection | Add a connection | Save configuration | Quit]
Use case 3: Connect to a given network
Code:
nmtui connect name|uuid|device|SSID
Motivation: This command allows users to connect to a specific network by providing the name, UUID, device, or SSID of the network. It can be useful when manually connecting to a network that is not automatically detected.
Explanation: The ’nmtui connect’ command followed by the name, UUID, device, or SSID of the network is used to connect to a specific network.
Example output:
Connected successfully to the network 'My WiFi Network'.
Use case 4: Edit/Add/Delete a given network
Code:
nmtui edit name|id
Motivation: This command provides a convenient way to edit, add, or delete a specific network connection. It allows users to modify network settings or add new connections without directly editing configuration files.
Explanation: The ’nmtui edit’ command followed by the name or ID of the network is used to edit, add, or delete a specific network connection.
Example output:
Editing the network connection 'Wireless connection 1'...
[Edit a connection | Save configuration | Quit]
Use case 5: Set the system hostname
Code:
nmtui hostname
Motivation: This command allows users to set the system hostname without directly editing system configuration files. It provides a convenient way to update the hostname.
Explanation: The ’nmtui hostname’ command is used to set the system hostname.
Example output:
Current hostname: my-hostname
Set new hostname [my-hostname]:
Conclusion:
The ’nmtui’ command is a powerful text user interface for controlling NetworkManager. It allows users to interactively manage network connections and settings. With its various use cases, such as opening the user interface, managing available connections, connecting to specific networks, editing/adding/deleting network connections, and setting the system hostname, ’nmtui’ provides a versatile tool for network management.