nmcli Command - NetworkManager CLI Tool for Linux

Master the nmcli command for Linux network management. Connect to WiFi, manage connections, view device status, and import VPN configurations with this essential CLI tool.

nmcli Command - NetworkManager CLI Tool

The nmcli command is a powerful command-line interface tool for controlling NetworkManager. It allows you to manage network connections, devices, and settings on Linux systems. This guide provides essential nmcli commands for common networking tasks.

Connect to a Wireless Access Point

To connect to a WiFi network, you need to specify the wireless interface, the SSID (network name), and the password.

# Connect to a wireless access point - Parameters:
# 	<wiface> -- the name of your wireless interface
#	<ssid> -- the SSID of the access point
#	<pass> -- the WiFi password
nmcli d wifi connect <ssid> password <pass> iface <wiface>

Disconnect from WiFi

To disconnect from a currently active WiFi connection.

# Disconnect from WiFi - Parameters:
#	<wiface> -- the name of your wireless interface
nmcli d wifi disconnect iface <wiface>

Manage WiFi Radio Status

Check the current status of the WiFi radio or enable/disable it.

# Get WiFi status (enabled / disabled)
nmcli radio wifi

# Enable / Disable WiFi
nmcli radio wifi <on|off>

List Available WiFi Networks

Scan for and list all available WiFi access points in your vicinity.

# Show all available WiFi access points
nmcli dev wifi list

# Refresh the available WiFi connection list
nmcli dev wifi rescan

Manage Network Connections

View and manage all configured network connections.

# Show all available connections
nmcli con

# Show only active connections
nmcli con show --active

Review Network Devices

Get an overview of all network devices recognized by NetworkManager.

# Review the available devices
nmcli dev status

Add an Ethernet Connection

Create a new dynamic Ethernet connection.

# Add a dynamic ethernet connection - parameters:
#	<name> -- the name of the connection
#	<iface_name> -- the name of the interface
nmcli con add type ethernet con-name <name> ifname <iface_name>

Import VPN Configurations

Easily import VPN connection settings from a configuration file.

# Import OpenVPN connection settings from file:
nmcli con import type openvpn file <path_to_ovpn_file>

Activate a Connection

Bring up a specific network connection.

# Bring up the ethernet connection
nmcli con up <name>

Show WiFi Password and QR Code

Retrieve details about a WiFi connection, including its password and a QR code for easy sharing.

# Show WiFi password and QR code
nmcli dev wifi show

For more advanced usage and options, consult the official NetworkManager documentation.

External Resources: