nmcli
: NetworkManager Command-Line Interface
Summary
nmcli
is a powerful command-line tool for controlling NetworkManager, allowing you to manage network connections, devices, and settings directly from the terminal.
Introduction
nmcli
(NetworkManager Command-Line Interface) is a command-line tool used for controlling NetworkManager, a system network service that manages network devices and connections on Linux systems. nmcli
provides a way to create, modify, activate, and deactivate network connections, as well as manage network devices and monitor their status. It's especially useful in scripts and when a graphical interface is not available.
Use case and Examples
Displaying Network Connections
This command lists all available network connections, including their name, UUID, type, and device.Activating a Network Connection
This command activates the network connection named "My Wired Connection". Replace "My Wired Connection" with the actual name of your connection.Deactivating a Network Connection
This command deactivates the network connection named "My Wired Connection". Replace "My Wired Connection" with the actual name of your connection.Connecting to a Wi-Fi Network
This command connects to the Wi-Fi network named "MyWiFiNetwork" using the provided password "MyWiFiPassword". Replace with your actual network name and password.Creating a New Wired Connection
This command creates a new wired connection named "NewWiredConnection" on the ethernet interface "eth0". Replace eth0 with your interface. You can then configure IP settings usingnmcli connection modify
. Commonly used flags
Flag | Description | Example |
---|---|---|
connection show | Displays network connections | nmcli connection show |
device status | Shows the status of network devices | nmcli device status |
connection up | Activates a network connection | nmcli connection up "My Connection" |
connection down | Deactivates a network connection | nmcli connection down "My Connection" |
device wifi list | Lists available Wi-Fi networks | nmcli device wifi list |
device wifi connect | Connects to a Wi-Fi network | nmcli device wifi connect "MyWiFi" password "password" |
connection modify | Modifies an existing connection | nmcli connection modify "My Connection" ipv4.addresses 192.168.1.100/24 |
connection delete | Deletes a network connection | nmcli connection delete "My Connection" |