4

I have installed Ubuntu 14.04 server and I need to connect to my WiFi network. How can I connect to my WiFi network using only the command line.

1

1 Answer 1

10

First run iwconfig to see if the wireless extensions are enabled.

sudo su
iwconfig

If you are informed that there is a card, for example wlan0 and wireless interface is recognized as you are going to:

Second to view the available wireless networks run iwlist

sudo su
iwlist wlan0 scan

Networks will show at your fingertips. Note the proper ESSID, which then need to enter.

Third, knowing the ESSID and the network password, run:

sudo su
ifconfig wlan0 up
iwconfig wlan0 essid <ESSID>
iwconfig wlan0 key s:<password_wireless>

In the last command, the s: is to indicate that what is below is a sequence of characters.

If the key is in hexadecimal numbers put the key starting with 0x:

Fourth, you must request an IP address from the DHCP server, or by ifconfig if you give the IP, netmask, gateway, etc.:

sudo su
dhclient wlan0

The steps can be automated script:

sudo su
nano /etc/init.d/wifi-on.sh

A simple text file with the following content:

!/bin/bash
ifconfig wlan0 up
iwconfig wlan0 essid <ESSID>
iwconfig wlan0 key s:<password_wireless>
dhclient wlan0

Control + O. save file. Control + X, close nano.

And you give execute permissions and add the system startup:

sudo su
chmod 755 /etc/init.d/wifi-on.sh
update-rc.d wifi-on.sh defaults
2
  • what if the network requires a username?
    – Mixone
    Aug 21, 2016 at 18:07
  • 2
    This answer only works for WEP networks. Oct 10, 2016 at 15:07

Not the answer you're looking for? Browse other questions tagged .