Skip to content

Master Network Management with nmcli Command

Discover the capabilities of nmcli, a robust command-line utility for managing NetworkManager. Explore a range of functionalities including checking online status, obtaining general status information, listing available devices and connections, importing configurations, changing hostnames, deleting setups, reloading connections, controlling interface status, connecting to Wi-Fi networks, creating Wi-Fi hotspots, managing VPN connections, setting DNS, and more. Take full control of your network configuration with nmcli.


Add wireguard connection to networkmanager in tray

nmcli connection import type wireguard file wireguard_config.conf

Display info of current network interfaces

nmcli connection show     

Ask networkmanager about online status

nm-online

Get General status

nmcli general

Listing NetworkManager polkit permissions

nmcli general permissions

Print info line by line

nmcli dev show

List all the available device

nmcli dev status

Show info about connections

nmcli connection show

Import wireguard config to nmcli

nmcli connection import type wireguard file "/path/to/wg0.conf"

Show devices

nmcli devices

Show the Network Manager status of all network interfaces

nmcli dev status

List all connection

nmcli con show

List the current settings for the connection name

nmcli con show name

Check if NetworkManager is running

nmcli -t -f RUNNING general

List all the configuration of interface

nmcli con show eno1

Change hostname using nmcli

nmcli general hostname

Delete setup

nmcli con del "eth1"

Delete Setup

nmcli con del "Wired connection 1"

Reload connection using nmcli (restart)

nmcli con reload

Set Wifi down

nmcli connection down id Wifi

Set Wifi up

nmcli connection up id Wifi

Set Modem down

nmcli connection down id MODEM

Set Modem up

nmcli connection up id MODEM

Set Ethernet down

nmcli connection down id Wired

Set Ethernet up

nmcli connection up id Wired

```

Set vpn connection up

nmcli --ask con up my-vpn-con

Set DNS

nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"

Ignore autodns

nmcli con mod <connectionName> ipv4.ignore-auto-dns yes

Show active connections

nmcli -g name,type connection  show  --active|awk -F: '/ethernet|wireless/ { print $1 }'

Show what I am actually connected to

nmcli -f GENERAL.CONNECTION,IP4.ADDRESS,IP4.GATEWAY dev show eno1

Show current ip addresses only

nmcli -f GENERAL.CONNECTION,IP4.ADDRESS,IP4.GATEWAY dev show eno1 \
| awk 'NR>1 {print $2}'

Wifi

Connect instant to a wifi access point

nmcli dev wifi connect "SSID" password "pass" hidden yes
Field Description
IN-USE * if currently connected
SSID Network name
BSSID Access point MAC address
MODE Infrastructure / Ad-Hoc / AP
CHAN Channel number
FREQ Frequency in MHz
RATE Max bitrate
SIGNAL Signal strength (0–100)
BARS Graphical signal indicator
SECURITY Security summary (WPA2, WPA3, etc.)
WPA-FLAGS WPA capabilities
RSN-FLAGS RSN (WPA2/WPA3) capabilities
DEVICE Wi-Fi interface used
ACTIVE yes/no
DBUS-PATH D-Bus object path

View ssids and channels of wifi´s in range

nmcli -f IN-USE,SSID,CHAN,SIGNAL,SECURITY dev wifi list

View ssids, channels and security of networks in range

nmcli -f IN-USE,SSID,CHAN,SIGNAL,SECURITY dev wifi list

View full options for wifi´s in range

nmcli -f all dev wifi list    

Listing available Wi-Fi APs

nmcli device wifi list

Connect to a password-protected wifi network

SSID="ssid"
PASSWORD="WPA3-PASS"
nmcli device wifi connect "$SSID" password "$PASSWORD"

Connect to a password-protected wifi network and get asked for password

SSID="ssid"
nmcli --ask device wifi connect "$SSID"

Showing general information and properties for a Wi-Fi interface

nmcli -p -f general,wifi-properties device show wlan0

Add wifi-hotspot helpo

nmcli dev wifi hotspot

Create a wifi-hotspot in a one-liner

nmcli dev wifi hotspot ifname wlp0s20f0u9u3 ssid MyAP password supersecret

Create wifi-hotspot

nmcli dev \
    wifi hotspot \
    ifname wlp2s0 \
    con-name  wuseman \
    ssid SSID-wuseman \
    password "SSID-wuseman-password"

Show wifi password

nmcli dev wifi show-password

Detect evil twins

nmcli -t -f SSID,BSSID,SIGNAL dev wifi list \
| sort \
| awk -F: '
{ count[$1]++; data[$1]=data[$1] "\n  " $2 " (" $3 "%)" }
END {
  for (s in count)
    if (count[s] > 1)
      print "⚠ Duplicate SSID:", s, data[s]
}'

Show hidden networks

nmcli -f IN-USE,SSID,BSSID,CHAN,SIGNAL,SECURITY dev wifi list --rescan yes

Measure wifi signal over time

while true; do
  nmcli -t -f ACTIVE,SIGNAL dev wifi list | grep '^yes'
  sleep 1
done

Toggle wifi like a hardware kill switch

nmcli radio wifi off
sleep 2
nmcli radio wifi on    

Force reconnect (Without Downing Interface)

nmcli connection down id "YourConnection"
nmcli connection up id "YourConnection"

Lock to Specific BSSID (Avoid Roaming)

nmcli connection modify "SSID" 802-11-wireless.bssid AA:BB:CC:DD:EE:FF
nmcli connection up "SSID"    

Create a disposable wifi profile (No Save)

nmcli dev wifi connect "SSID" password "pass" --temporary

Show Channel Congestion Fast

nmcli -t -f CHAN,SIGNAL dev wifi list \
| sort -t: -k1 -n

List All Supported WiFi Capabilities

nmcli device show wlp0s20f0u9u3 | grep WIFI

Bonus: Ultimate Minimal WiFi Overview

nmcli -f IN-USE,SSID,CHAN,FREQ,SIGNAL,SECURITY,BARS dev wifi list

MAC Address Randomization

Enable random MAC on connect

nmcli connection modify "SSID" 802-11-wireless.cloned-mac-address random
  • Disable:
nmcli connection modify "SSID" 802-11-wireless.cloned-mac-address permanent

Show passwords tutorial

Display saved wi-fi password (psk) for a connection profile

nmcli -t -f NAME,TYPE connection show | awk -F: '$2=="802-11-wireless"{print $1}'

List saved wi-fi connection profiles

nmcli -s -g 802-11-wireless-security.psk connection show "PROFILE_NAME"

DNS

Show current dns

nmcli device show | grep IP4.DNS 

Find the correct name so we can set correct dns

nmcli connection show

Add new dns

nmcli connection modify "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"