Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


NetworkManager nmcli

A network management software for Ethernet, WiFi, DSL, VPN, etc, and mobile broadband network connections. NetworkManager is a program for providing detection and configuration for systems to automatically connect to networks (wired and wireless). nmcli is it's official command line interface, about which we will focus here.

Tip

If you don't want to use a CLI tool, then choose a GUI one: a lot of GUI front-ends are available](https://wiki.archlinux.org/title/NetworkManager#Front-ends). In addition, nmtui is very nice and simple TUI alternative.

Reference(s)

Table of contents


Install

TODO


# pacman -S networkmanager

For Artix users

  • If using openrc:
    # pacman -S cronie networkmanager-openrc
    
  • If using runit:
    # pacman -S cronie networkmanager-runit
    
  • If using s6:
    # pacman -S cronie networkmanager-s6
    

TODO


TODO


TODO



Config

Now, add NetworkManager to your init manager:

# rc-update add NetworkManager default
# /etc/init.d/NetworkManager start

Depending on your runit implementation, either run:

# ln -s /etc/runit/sv/NetworkManager /service
or run:
# ln -s /etc/runit/sv/NetworkManager /var/service
or run:
# ln -s /etc/runit/sv/NetworkManager /run/runit/service
In any case, finally run:
# sv up NetworkManager

# service NetworkManager start
# chkconfig NetworkManager on
# systemctl enable NetworkManager
# systemctl start NetworkManager

Use

Status

  • Get NetworkManager global status:

    $ nmcli
    $ nmcli device status
    $ nmcli dev status
    

  • Print whether NetworkManager is running or not:

    $ nmcli -t -f RUNNING general
    

  • Print whether NetworkManager general state:

    $ nmcli -t -f STATE general
    

  • Show all configured connections (active connections are green and inactive ones are white):

    $ nmcli con show
    $ nmcli connection show
    

  • Show all configured connections in multi line mode:

    $ nmcli -p -m multiline -f all con show
    

  • List all currently active connections:

    $ nmcli connection show --active
    

  • Show static configuration details of a specific connection:

    $ nmcli -f profile con s "SSID or BSSID"
    

Connection

  • Activate a specific connection:

    $ nmcli con up "SSID or BSSID"
    

  • Activate a specific connection showing the progress of the activation:

    $ nmcli -p con up "SSID or BSSID"
    

  • Activate a specific connection with interactive password:

    $ nmcli --ask con up "SSID or BSSID"
    

  • Deactivate a specific connection:

    $ nmcli con down "SSID or BSSID"
    

  • Show details for a specific connection:

    nmcli -p connection show "SSID or BSSID"
    

Wi-Fi

  • Switch Wi-Fi off and on:

    $ nmcli radio wifi off
    $ nmcli radio wifi on
    

  • List available Wi-Fi:

    $ nmcli device wifi list
    $ nmcli dev wifi list
    

  • Connect to a password protected Wi-Fi network:

    $ nmcli dev wifi connect "SSID or BSSID" password "your password"
    

  • Connect to a password protected Wi-Fi network interactively:

    $ nmcli --ask dev wifi connect "SSID or BSSID"
    

After your first connection, the password used will be saved, so the next time you can just run: nmcli con up "SSID or BSSID".

  • shows details for "SSID or BSSID" connection profile with all passwords:

    $ nmcli --show-secrets con show "SSID or BSSID"
    

  • Showing general information and properties for a Wi-Fi interface (e.g. wlan0):

    $ nmcli -p -f general,wifi-properties dev show wlan0
    

  • Create a hotspot profile and connects it (also print the hotspot password the user should use to connect to the hotspot from other devices) WIP:

    $ nmcli -s dev wifi hotspot con-name QuickHotspot
    

Editor

WIP

  • Edit existing "SSID or BSSID" connection in the interactive editor:

    nmcli connection edit ethernet-em1-2
    

  • Add a new Ethernet connection in the interactive editor:

    nmcli connection edit type ethernet con-name "yet another Ethernet connection"
    

TODO

MAC address

Reference(s)

Change the MAC address of an interface (e.g. interface enp1s0 with the new MAC address 00:12:34:56:78:9a):

$ sudo nmcli connection modify enp1s0 ethernet.cloned-mac-address 00:12:34:56:78:9a


If this cheat sheet has been useful to you, then please consider leaving a star here.