I'd like to connect to a wireless access point from the command-line. Ideally, I'd only need the name of the AP. But the hardware-address would work as well.

I know I can use nmcli to connect to a managed network connection, but in my case, the access point may not be configured for Network-Manager yet (See the difference between the output of nm-tool and nmcli con).

Example output of nmcli:

Auto pwln       3a3d62b1-bbdf-4f76-b4d2-c211fd5cfb03   802-11-wireless [...]  
Wired Network   aa586921-accf-4932-98c4-c873c310f08e   802-3-ethernet [...]  
Cisco-UDP Uni   7f94847b-04dc-40b7-9955-5246fb77cc65   vpn [...]  
T-mobile (D1)   867f345a-cbbf-4bd4-b883-a5e5ae0932f0   gsm  [...]

Example output of nm-tool:

State: connected
- Device: eth1  [Auto pwln] ----------------------------------------------------
  Wireless Access Points (* = current AP)
    *pwln: Infra, [...], Freq 2472 MHz, Rate 54 Mb/s, Strength 80 WPA WPA2
    WLAN:  Infra, [...], Freq 2422 MHz, Rate 54 Mb/s, Strength 20 WPA WPA2


How do I connect to an access point that may or may not be known to NM?

Extra: Finding out if the connection needs a pass-phrase, and submitting it on the command-line as well would be great too (that is to say It'd be nice if network-manager wouldn't pop open any keyring dialogues or errors on the gui)

4 Answers 4


You can do this directly using nmcli, even if the connection isn't configured in Network Manager yet:

nmcli dev wifi con "myssid" password "myssidpassword"

If you don't want to have the wireless password stored in your history in recent versions (maybe newer than mentioned below) you can add --ask to have nmcli prompt you for missing information it needs.

nmcli --ask device wifi connnect "myssid"

This facility was added in Network Manager 0.9.6, so this only works in Ubuntu 12.10 or later.

You can also get a list of available access points with:

nmcli dev wifi list
  • con is not recognized by nmcli dev wifi
    – kaiser
    Sep 15, 2014 at 13:32
  • What version are you using? It works for me, and is documented as an example in the manpage. Sep 15, 2014 at 14:58
  • nmcli -v is
    – kaiser
    Sep 15, 2014 at 15:04
  • So you're using 12.04? As I said in my answer, this only works on Ubuntu 12.10 or later. Sep 16, 2014 at 11:45
  • This might be the case. I wonder if I could sudo apt-get update it.
    – kaiser
    Sep 16, 2014 at 11:54

You can use cnetworkmanager for this.


After some investigation it becomes clear that it is impossible to run two "user configuration providers" (an application listening at a certain dbus address) at the same time, and cnetworkmanager needs to act as such a "configuration provider" (at least until the connection is set up).

Now, what you can do is add the information for the connection to gconf under the /system/networking/connections key (you can do that from the commandline or a script), and then use dbus or a command-line tool like cnetworkmanager or nmcli to connect to it. Maybe you'll also have to add the key to the user's keyring first (to avoid password popups).

But of course that won't work on a desktop that uses another NM-client than nm-applet (e.g. KDE). You would have to figure out how to provide a config for them too...

Edit 2:

It seems like it might be possible via org.freedesktop.NetworkManagerUserSettings on the system DBus, but this is all poorly documented IMO...

You might want to read about configuration settings and the DBus interface spec.

And here is a relevant example (maybe you want to set up a user connection instead of a system connection though)

  • Still nothing. Unfortunately, cnetworkmanager will not work properly besides the networkmanager-applet ("Another applet is running") Oct 20, 2010 at 22:37
  • I did read up on how NM & nm-applet works & edited my answer.
    – JanC
    Oct 21, 2010 at 1:01

You can use iwconfig (wifitools) for wep encryption, or wpa_supplicant for wpa and wep, also you use wicd-curses if you're looking for something easier, good luck =)

  • I'd really want to use network-manager, maybe via dbus. I can't mess about with the operating system too much, since the program i'm writing isn't only going to run on my own machine. All the configuration, where possible, should remain unchanged. Oct 19, 2010 at 18:50

You can check out iwconfig and iwlist:

  • iwconfig manipulate the basic wireless parameters
  • iwlist allow to initiate scanning and list frequencies, bit-rates, encryption keys...

There are many options. Check out Wireless Tools for Linux for more.

  • 2
    As I said, I'd like to integrate with network-manager, not replace it. Oct 19, 2010 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.