nmcli Cheatsheet
Quick reference for using nmcli to manage NetworkManager devices, connection profiles, Wi-Fi, static IP addresses, DNS, and troubleshooting
The `nmcli` command controls NetworkManager from the terminal. This cheatsheet covers the common commands for checking network status, managing devices and profiles, connecting to Wi-Fi, configuring static IP addresses, and troubleshooting network changes.
Basic Syntax
Use this structure for most nmcli commands.
| Command | Description |
|---|---|
nmcli [OPTIONS] OBJECT COMMAND | General command syntax |
nmcli OBJECT help | Show help for an object |
nmcli --version | Show nmcli version |
nmcli -t ... | Use terse output for scripts |
nmcli -f FIELD1,FIELD2 ... | Select output fields |
nmcli -g FIELD ... | Print field values only |
General Status
Check NetworkManager state and hostname settings.
| Command | Description |
|---|---|
nmcli general status | Show overall NetworkManager status |
nmcli networking connectivity | Check internet connectivity state |
nmcli general hostname | Show system hostname |
sudo nmcli general hostname server01 | Set system hostname |
nmcli general permissions | Show NetworkManager permissions |
nmcli general logging | Show logging level and domains |
Devices
Inspect and control network interfaces.
| Command | Description |
|---|---|
nmcli device status | List devices and connection state |
nmcli device show eth0 | Show detailed device properties |
nmcli -f GENERAL,IP4 device show eth0 | Show selected device sections |
sudo nmcli device connect eth0 | Connect a device |
sudo nmcli device disconnect eth0 | Disconnect a device |
nmcli device reapply eth0 | Reapply active profile settings |
Connection Profiles
Manage saved NetworkManager profiles.
| Command | Description |
|---|---|
nmcli connection show | List all profiles |
nmcli connection show --active | List active profiles |
nmcli connection show "home-wifi" | Show one profile |
sudo nmcli connection up "home-wifi" | Activate a profile |
sudo nmcli connection down "home-wifi" | Deactivate a profile |
sudo nmcli connection delete "home-wifi" | Delete a saved profile |
Wi-Fi
Scan networks and connect to wireless profiles.
| Command | Description |
|---|---|
nmcli radio wifi | Show Wi-Fi radio state |
sudo nmcli radio wifi on | Turn Wi-Fi on |
sudo nmcli radio wifi off | Turn Wi-Fi off |
nmcli device wifi list | Scan visible Wi-Fi networks |
sudo nmcli device wifi connect "SSID" password "PASSWORD" | Connect with password |
sudo nmcli --ask device wifi connect "SSID" | Prompt for Wi-Fi password |
sudo nmcli device wifi connect "SSID" password "PASSWORD" hidden yes | Connect to hidden network |
Static IPv4
Set or remove manual IPv4 settings on a profile.
| Command | Description |
|---|---|
sudo nmcli connection modify "Wired connection 1" ipv4.method manual | Use manual IPv4 |
sudo nmcli connection modify "Wired connection 1" ipv4.addresses 192.168.1.50/24 | Set static address |
sudo nmcli connection modify "Wired connection 1" ipv4.gateway 192.168.1.1 | Set gateway |
sudo nmcli connection modify "Wired connection 1" ipv4.dns "1.1.1.1 9.9.9.9" | Set DNS servers |
sudo nmcli connection up "Wired connection 1" | Apply profile changes |
nmcli -g IP4.ADDRESS,IP4.GATEWAY connection show "Wired connection 1" | Check IPv4 settings |
DHCP and DNS
Return to DHCP or adjust DNS servers.
| Command | Description |
|---|---|
sudo nmcli connection modify "Wired connection 1" ipv4.method auto | Use DHCP for IPv4 |
sudo nmcli connection modify "Wired connection 1" ipv4.addresses "" | Clear static address |
sudo nmcli connection modify "Wired connection 1" ipv4.gateway "" | Clear static gateway |
sudo nmcli connection modify "Wired connection 1" ipv4.dns "" | Clear static DNS |
sudo nmcli connection modify "Wired connection 1" +ipv4.dns 8.8.8.8 | Append DNS server |
sudo nmcli connection modify "Wired connection 1" -ipv4.dns 8.8.8.8 | Remove DNS server |
Add Profiles
Create new wired and wireless profiles.
| Command | Description |
|---|---|
sudo nmcli connection add type ethernet ifname eth0 con-name "wired-dhcp" | Add wired DHCP profile |
sudo nmcli connection add type ethernet ifname eth0 con-name "wired-static" ip4 192.168.1.50/24 gw4 192.168.1.1 | Add wired static profile |
sudo nmcli connection add type wifi ifname wlan0 con-name "office-wifi" ssid "Office" | Add Wi-Fi profile |
sudo nmcli connection modify "office-wifi" wifi-sec.key-mgmt wpa-psk | Set WPA-PSK security |
sudo nmcli connection modify "office-wifi" wifi-sec.psk "PASSWORD" | Set Wi-Fi password |
sudo nmcli connection up "wired-static" | Activate new profile |
Scripting Output
Use stable output formats in scripts.
| Command | Description |
|---|---|
nmcli -t connection show --active | Terse active profile list |
nmcli -t -f NAME,DEVICE connection show --active | Active names and devices |
nmcli -g GENERAL.STATE device show eth0 | Print device state value |
nmcli -g IP4.ADDRESS device show eth0 | Print IPv4 address values |
nmcli -f DEVICE,TYPE,STATE device status | Select device status fields |
nmcli -m multiline connection show "home-wifi" | Multiline profile details |
Monitor and Reload
Watch changes and reload profile files.
| Command | Description |
|---|---|
nmcli monitor | Watch NetworkManager events |
nmcli device monitor eth0 | Watch one device |
sudo nmcli connection reload | Reload profile files from disk |
sudo nmcli general reload | Reload NetworkManager configuration |
sudo nmcli general reload dns-rc | Rewrite DNS resolver configuration |
journalctl -u NetworkManager -n 100 | Show recent NetworkManager logs |
Troubleshooting
Fast checks for common NetworkManager issues.
| Issue | Check |
|---|---|
| NetworkManager is not running | sudo systemctl start NetworkManager |
| Wi-Fi list is empty | sudo nmcli radio wifi on and rfkill list |
| Wrong profile is active | nmcli connection show --active |
| Static IP did not apply | sudo nmcli connection up "PROFILE" |
| DNS is not working | nmcli -g IP4.DNS device show eth0 |
| Permission denied | Run the command with sudo |
Related Guides
Use these articles for detailed networking workflows.
| Guide | Description |
|---|---|
nmcli Command in Linux | Complete nmcli command guide |
Linux ip Command with Examples | Interface, address, and route management |
How to Configure Static IP Address on Ubuntu | Netplan and desktop static IP setup |
How to Use the dig Command | DNS lookup and troubleshooting |
SSH Command in Linux | Remote shell access and options |
