nmcli is wicked

You don't need alttext here, this image is lame filler!

Remember how happy we were when finally got clicky with nm-applet?

I don’t know about you, but I’ve been wishing, hoping and waiting (not helping or coding of course!) a long time for a useable command line client for network-manager. cnetworkmanager came and went without anyone actually trying it, and then nmcli showed up.

nmcli syntax is a little less than intuitive, and if you’re like me it took you a while to notice that the problem you were having with it was not in fact that you couldn’t figure out the syntax, it was that it would not do the thing you were trying to get it to do!
Well eventually anyway. As it turned out it; would do 2 out of 3. That is you could:
bring up or down networks that network-manager already knew about:
nmcli con down id NetworkImDoneWith
nmcli con up id MyAwesomeNetwork
In the process of figureing that one out, we all learned to list nm’s known networks:
nmcli con list
Which does’nt count as one of the three, because while it’s kind of nostalgic to see an SSID you connected to in 2009 on that work trip to Illinois, until you’re wrestling with nmcli you’d never want to do this, it’s the equivalent opening nm-connection-editor and opining over each tab.

But oh boy were you excited that day at the coffee shop when you were practicing running your whole system from a framebuffer on tty1, and discovered that nmcli could list the _new_ networks available:
nmcli dev wifi


If it can list them surely we can connect to them!

Alas, it was not to be. After plugging through all the syntactic options for nmcli and it’s dev,nm,con subcommands you gave up and hit ctrl+alt+f7 logged into to X and clickyclickyclickied on “aztec cafe” so easy and so defeating.

You knew someday you would not suffer so.

That time is now!

The nmcli that comes with network-manager 0.9.6 ( is already in debian experimental) includes the all new “wifi connect” command:

$ nmcli dev help
Usage: nmcli dev { COMMAND | help }

COMMAND := { status | list | disconnect | wifi }

list [iface ]
disconnect iface [–nowait] [–timeout ]
wifi [list [iface ] [bssid ]]
wifi connect <(B)SSID> [password ] [wep-key-type key|phrase] [iface ] [bssid ][name ][–private] [–nowait] [–timeout ]

That mess translates into, You can now finally attach to a new network:
“Hmm are there are any networks here?”
nmcli dev wifi
'JoesHouse' 00:30:DE:AD:BE:EF Infrastructure 2412 MHz 54 MB/s 67 WPA WPA2 no

“Sweet, oh wait it’s wpa, ‘Hey Joe what’s your wifi password?, Cool thanks'”
nmcli dev wifi connect JoesHouse password correcthorsebatterystaple

Effing finally. 😀

( /me is accepting wagers on whether someone mentions pkexec in the comments)

 sam is a free software enthusiast and network admin in Santa Fe, NM Read more from this author

4 Responses to “nmcli is wicked”

  • salantraxNo Gravatar Says:

    Thank you for summing up. Effing finally indeed. Now off I go, to find out if I can use and control every last bit of NM from that framebuffer titty no.1.

  • FuriousNo Gravatar Says:

    Hi. Finally found some commands that work 😛 All i need left is to find out how to enable and disable “mobile broadband”. Cause I have to reset it every time i lose Internet connection I want to write a script to do it for me. Can you help?

  • samNo Gravatar Says:


    I don’t have anything running that NM sees as a mobile broadband device. (When I tether my phone it looks like a usb ethernet.) But if you’ve got something like a built in wlan card or a feature phone that uses ppp, I imagine the device will be in the list with:
    $nmcli dev status

    But either way you’re going to already have a “connection” defined. So you ought to be able to use the example above:
    $nmcli con down id NetworkImDoneWith
    $nmcli con up id MyAwesomeNetwork

    Just using your mobile “con” for both the down and up.
    I see I still have a t-zones con saved from when I had a feature phone:
    $ nmcli con | grep Tzones
    Tzones 0bcabd7b-1dbc-448b-84b0-1d64f6dj7760 gsm never

    So I bet if I still had the phone:
    $nmcli con down id Tzones
    $nmcli con up id Tzones

    Would do the job.

    If not you could play with replacing the con down command with a dev disconnect:

    $nmcli dev disconnect iface my_mobile_broadband_device
    $nmcli con up id my_mobile_provider

  • NetworkManager and dnsmasq Says:

    […] Another way to get a glimpse at the current state is using nm-tool or nmcli . […]

Leave a Reply