Linux For Cynics One user's experiences with Linux


Wifi from Command Line

In this short how-to I'll show you how to connect to a WPA wifi network from the network without any GUI tools.

First, we have to install the relevant software. Some distros do not come with much wifi firmware or wpa support out of the box and they must be installed after the fact. In Debian, follow this guide to install them.

Display the currently active network interfaces:

$ sudo iwconfig

You should see something like wlan0. Let's activate it:

$ sudo ifconfig wlan0 up

Optional if you know the SSID of the network you want:
Scan the interface for access points:

$ sudo iwlist wlan0 scan

Open the /etc/network/interfaces file (replace editor with text editor of your choice):

$ sudo editor /etc/network/interfaces

and add an entry for the network you want to join (replace words in CAPS with your details, where NAME is what you want to call the entry):

iface NAME inet dhcp
  wpa-ssid YOUR-SSID

Now, just connect to that network!

$ ifup wlan0=NAME

To connect to a different network, simply add another entry to /etc/network/interfaces and run ifup wlan0=NEW-NETWORK-NAME.

Comments (1) Trackbacks (0)
  1. Nice tutorial. Might want to add that if your essid for the network contains spaces, you should quote-enclose the essid name.

Leave a comment

No trackbacks yet.