Set up wireless in Linux via the command line

I recently bought an Acer Revo 3600 to replace my ageing PopcornHour A100. I’ve installed a minimal version of Ubuntu Linux on it as well as xbmc. As this is in my bedroom far away from my router, I only wanted to use the wireless chip.

As I have no gui, I have to manually set this up. If you do happen to be in some sort of gui and want to get out of it quickly, just press ctrl+alt+f1 or ctrl+alt+f2 and so on. This will just open up another terminal session for you.

You’ll need to know the name of your SSID as well as your password of course. In my case here I’m using WPA2. You’ll need to have wpasupplicant installed. If you have a wired connection it’ll be easy to install. If not you’ll need to get it elsewhere and copy it on your box. I am using Ubuntu, so the same method should work with Debian. Just use your distro’s packet manager to get it installed.

sudo apt-get install wpasupplicant

If not already root, you’ll now need to log in as root

sudo su -

Now you need to type wpa_passphrase ssid password > /etc/wpa_supplicant.conf. This is my example:

wpa_passphrase Cisco Thisisyourpassk\$y > /etc/wpa_supplicant.conf

As this is Linux, you need to remember to use break characters when using special characters. My ssid is named Cisco and my password is Thisisyourpassk$y. I’ve used the break character just before the $ sign. You will see if you have this correct by opening up the /etc/wpa_supplicant.conf file like so:

vi /etc/wpa_supplicant.conf

You should see that the break character worked as the psk over here shows the correct password in full.

Copy the psk value as you’ll need it in the next step.

Open your interface config file (in Ubuntu/Debian it’s over here):

vi /etc/network/interfaces

Add the following to this file:

#The wireless interface
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "Cisco"
wpa-ap-scan 1
wpa-key-mgmt WPA-PSK
wpa-psk "357b62bf79a0d096901fe32d3138b6d962b95675976f08d044d117970b04d0fa"

Save and exit. Now restart your network:

/etc/init.d/networking restart

You should now be connected, and can monitor it via ifconfig and iwconfig:

[email protected]:~# iwconfig 

wlan0     IEEE 802.11bg  ESSID:"Cisco"
          Mode:Managed  Frequency:2.472 GHz  Access Point: 00:1D:A2:E7:56:30
          Bit Rate=54 Mb/s   Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:7B16-2A4A-9A61-158A-9537-84FE-3F90-E275 [3]
          Power Management:off
          Link Quality=36/70  Signal level=-74 dBm  Noise level=-94 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
[email protected]:~# ifconfig
wlan0     Link encap:Ethernet  HWaddr 0c:60:76:68:60:25
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::e60:76ff:fe68:6025/64 Scope:Link
          RX packets:649 errors:0 dropped:0 overruns:0 frame:0
          TX packets:677 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:94586 (94.5 KB)  TX bytes:123349 (123.3 KB)

This only works if your kernel actually has the driver of course. If not, you may need to download the windows driver and use ndiswrapper. I’ve got an exmple of doing this in my post over here:

I would also suggest deleting your /etc/wpa_supplicant.conf file to prevent anyone in future getting your password.

© 2009-2020 Darren O'Connor All Rights Reserved -- Copyright notice by Blog Copyright