The Basics: A Working nmcli Cheatsheet

Get WiFi status (enabled / disabled)

nmcli radio wifi

Enable / Disable WiFi

nmcli radio wifi <on|off>
  • <on|off>: to turn on/off the WiFi

Disconnect from WiFi

nmcli device disconnect <wiface>
  • <wiface>: the name of your wireless interface (e.g. wlan0)

Show all available WiFi access points

nmcli dev wifi list

Refresh the available WiFi connection list

nmcli dev wifi rescan

Connect to a wireless access point

nmcli d wifi connect <ssid> password <pass> iface <wiface>
  • <wiface>: the name of your wireless interface
  • <ssid>: the WiFi’s name you want to connect to
  • <pass>: the WiFi password

Review the available devices

nmcli dev status

Add a dynamic ethernet connection

nmcli con add type ethernet con-name <name> ifname <iface_name>
  • <name>: the name you want to give this connection profile
  • <iface_name>: the name of the interface to bind it to (e.g. eth0)

Bring up the ethernet connection

nmcli con up <name>
  • <name>: the name of the connection profile to activate (the same <name> used when adding it)

Show WiFi password and QR code for the active connection

nmcli device wifi show-password
# OR,
nmcli device wifi show

Getting a Prettier Wifi List

The default terse -t mode is colon-separated and built for scripts, not eyeballs:

nmcli -f SSID,BSSID,SECURITY,SIGNAL,DEVICE device wifi list
  • -f: to specify fields to output
  • SSID,BSSID,SECURITY,SIGNAL,DEVICE: the columns you want displayed

Setting a Custom Hostname Per-Connection

By default, your machine’s real hostname gets sent to the router via DHCP. If you don’t want that leaking (or you’re just tired of your router showing “Nix” or whatever your last distro reinstall left behind), you can override it per-connection:

nmcli con modify "MyWiFi" ipv4.dhcp-hostname "Galaxy-J2" ipv4.dhcp-send-hostname yes
  • "MyWiFi": your WiFi’s name
  • Galaxy-J2: the hostname to send to the router’s DHCP server instead of your real one

Now this profile alone will hand out “Galaxy-J2” over DHCP, leaving your actual hostname out of it.


MAC Address Spoofing: Per-Connection

You can override the MAC address NetworkManager uses for a specific saved connection:

nmcli connection modify "MyWiFi" 802-11-wireless.cloned-mac-address AA:BB:CC:DD:EE:FF
  • "MyWiFi": your WiFi’s name
  • AA:BB:CC:DD:EE:FF: the MAC address you want to use instead of the real one

Or let NetworkManager pick a fresh random one on every connection attempt:

nmcli connection modify "MyWiFi" 802-11-wireless.cloned-mac-address random
  • "MyWiFi": your WiFi’s name
  • random: picks a new random MAC every time you connect

Verify what’s actually stored in the profile:

nmcli -f 802-11-wireless.cloned-mac-address connection show "MyWiFi"
  • "MyWiFi": your WiFi’s name

MAC Address Spoofing: Globally, For Every Network

Setting cloned-mac-address per-connection gets tedious if you have a dozen saved networks, and it doesn’t help with new networks you haven’t connected to yet. For a true global default, NetworkManager reads config files under /etc/NetworkManager/conf.d/:

sudo mkdir -p /etc/NetworkManager/conf.d/
sudo tee /etc/NetworkManager/conf.d/99-global-mac-address.conf <<'EOF'
[connection-mac-randomization]
match-device=type:wifi
wifi.cloned-mac-address=DE:AD:BE:EF:CA:FE
EOF

sudo systemctl restart NetworkManager

Checking the Current Status (Global vs Per-Connection vs Live)

Since there are three layers involved, it helps to check them top-down when debugging.

1. What’s in the global conf.d file:

cat /etc/NetworkManager/conf.d/99-global-mac-address.conf

Or ask NetworkManager for its fully merged config (accounts for all conf.d files together):

sudo NetworkManager --print-config

2. What’s set on a specific connection profile:

nmcli -f 802-11-wireless.cloned-mac-address connection show "MyWiFi"

Loop it across every saved connection:

for conn in $(nmcli -t -f NAME connection show); do
  echo "== $conn =="
  nmcli -f 802-11-wireless.cloned-mac-address connection show "$conn" | grep cloned
done

3. What’s actually live on the interface right now:

nmcli -f GENERAL.HWADDR,GENERAL.DEVICE device show wlan0

Compare against the real, permanent factory MAC:

ethtool -P wlan0