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.
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