Technocrazian Hack the Code

Connecting to Wifi hot spots through command line

Heya,
For quite a few days, I have been trying different ways to connect to a wireless network (protected through WPA-PSK) via command line a.k.a cli. I tried using wpa_supplicant, iwconfig, editing /etc/network/interfaces etc. Silly me, I was not looking at the great "NetworkManager" which happen to have a cli version. It is called nmcli.
The following are the steps to connect to a wifi accesspoint from cli
1. List out all the available access points using the command
nmcli dev wifi list
2. Note the SSID of the access point you need to connect to and get its password
3. Connect to access point using the command
nmcli dev wifi connect password
Fill in for and eg : I have an accesspoint with name "Balu" and password "samplepassword". So to connect to it, I'll use
nmcli dev wifi connect Balu password samplepassword
4. Voila!!

I see this as the easiest way to connect to a wireless network. And as Rajeeshettan often says, NetworkManager is one of the best things that happened to GNU/Linux in quite some years.

 

Happy Hacking.