Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I connect to a wireless network using only the command line in Linux? The only thing I know is that iwconfig must be used, but how?

share|improve this question

The exact commands will depend on the network you're connecting to. I generally first use 'iwlist' to find a list of available networks.

iwlist wlan0 scanning

This will return a list of all wireless networks seen on interface wlan0.

The next step is to set the ESSID and what access point to use (usually automatic).

iwconfig wlan0 essid my_network
iwconfig wlan0 ap any

If the network is unsecured you're done configuring the wifi at this point. You can then set a static IP (ifconfig) or a request a dynamic IP (dhclient).

If the network is secured with WEP you'll need to enter the correct key.

iwconfig wlan0 enc s:my_network_key

If the network is secured with WPA(2) you'll need to install and configure wpa_supplicant first.

As always the manpage is the first place you should look for more information.

share|improve this answer
Not all wireless networks are seen on wlan0. I've got an Acer laptop where the wireless network is on eth1. I'd add a step to first check the correct interface using iwconfig – nagul Aug 14 '09 at 11:45
How do you know what to use as access point? – Shawn Oct 14 '09 at 19:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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