68

I am using my WiFi network adapter on the laptop to connect to the internet on Ubuntu 10.04. I have tried the following steps and got the below messages on the Ubuntu terminal. Please let me know what has gone wrong. Thank you.

I have used the following instructions I have seen on a web page.

  1. Open the terminal.

  2. Type ifconfig wlan0 and press Enter. You will not see any output in the terminal, as this command just turns your wireless card on. Most wireless cards are designated wlan0. If yours has a different designation, use that instead.

  3. Type iwconfig wlan0 essid name key password and press Enter. Replace name with the actual network name, and replace password with the actual security key for the network. If your wireless network does not require a security key, do not enter key password.

  4. Type dhclient wlan0 and press Enter to obtain an IP address and connect to the WiFi network.

What I see on the terminal are given below.

Alaa Ali
  • 31,535
user157947
  • 789
  • 1
  • 6
  • 4

1 Answers1

70

Okay, I'm going to try and answer your question, even though there is no terminal output included in your question.

  1. The command ifconfig wlan0 does not turn on your wireless card. It gives you information about your wlan0. To turn on your wireless card, you would enter ifconfig wlan0 up. Although, it's not always wlan0. To find out the name of your wireless card, type iwconfig, and look at the row that has some information in it, not 'no wireless extensions'.

  2. To be able to run the commands ifconfig wlan0 up, iwconfig wlan0 essid WIFI_NETWORK_HERE key PASSWORD_HERE and dhclient wlan0, you need to be root. So, you have to put the word sudo before those commands (unless you're already logged in as root).

  3. The password in the command iwconfig wlan0 essid name key password should be in hexadecimal. If you want to type the ASCII password, you would use iwconfig wlan0 essid name key s:password.

  4. The command iwconfig wlan0 essid name key password only works with access points that use WEP as encryption. If the access point uses WPA/WPA2, you'll have to use another method to connect, found here: How do I connect to a WPA wifi network using the command line?

Also, might I ask, is there a reason why you're trying to connect to a WiFi network through command line? Unless you're experimenting of course.

Alaa Ali
  • 31,535
  • Maybe change the wording and ask for the question to be merged? – Braiam Feb 02 '14 at 20:33
  • Ask for the question to be merged with what? – Alaa Ali Feb 02 '14 at 21:14
  • Should i replace essid with the name of the wifi network? can you put an example? – Arnold Roa Feb 21 '17 at 19:01
  • @ArnoldRoa replace name with the name of the wifi network, and password with the WEP key. So an example would be iwconfig wlan0 essid WIFI_NETWORK_HERE key PASSWORD_HERE. – Alaa Ali Feb 21 '17 at 23:06
  • What about for WiFi networks with no encryption? – Aaron Franke Oct 12 '17 at 05:48
  • @AaronFranke I believe encryption-free networks are connected to by ommitting key and everything thereafter, so it becomes iwconfig wlan0 essid WIFI_NAME. – Jarred Allen Mar 24 '18 at 00:20
  • I don't know about OP, but I'm connecting to WiFi via terminal because I have an old laptop running a fileserver(no GUI because it's a waste of resources), and I want a redundant connection in case the faster wired connection gets disrupted by someone messing with cables. – StarCrashr Sep 28 '18 at 01:37
  • You might want to connect using command line scripts for devices that do not have a GUI, or are not running one. – MikeW Jan 14 '19 at 11:43
  • When providing the password; Error for wireless request "Set Encode" (8b2a), Set failed on device ... invalid argument. Please can someone for the love of god post an answer with the syntax for the password? – Owl Jan 10 '20 at 10:30
  • 6
    "is there a reason why you're trying to connect to a WiFi network through command line?" - all too common on Raspberry Pi, especially distros with no GUI (X-windows or alternative not installed) – Mawg says reinstate Monica May 10 '20 at 08:00
  • I'm trying to connect my Raspberri Pi 4 running Ubuntu Server 20.04 LTS – Dany Mar 24 '21 at 09:36