Connecting to a network via Linux Terminal is as sweet as candy. Have you bumped into issues and unknown errors while trying to connect to WIFI network before?. If so, then you have to learn how to do it on command line interface. Some Linux flavors  and distributions will fail to connect to wifi network at some point but using Terminal to connect to WIFI network never fails.
If you’ve just installed your Linux, we have a lot of tutorials on How to for Linux.

This tutorial is universal and will work well on most Linux distros out there, both old and future releases. It also work well on both WPA/WPA2 wireless networks.

These are the tools you would require to connect to wireless network in Linux’s command line terminal.

1) Ping
2) ip
3) iw
4) wpa-supplicant

Brief summary of the tools mentioned.


It is anew 802.11 base CLI configuration utility for all wireless devices. It has support for all new drivers that have been added to the kernel recently.


It stands for Internet protocol. It is a utility in Linux used to test and show routing ,devices,policy routing and tunnels.


Supplicant is the IEEE 802.1X/WPA component uses at the client station. Its purpose is implementing key negotiation with a WPA Authentication and Controlling roaming and IEEE 802.11 authentication and association Wlan drivers.


Utility used to test whether destination host is live or dead. It uses ICMP echo messages.

Step 1: Finding all available Wifi and adapters.

Begin by finding all available Wifi and adapters with iw command . 

 # iw dev
  phy #1
  Interface wlan0
  ifindex 4
  wdev 0x1
  addr 00:27:10:0e:b3:54
  type managed

Wlan0 is the device names. Phy#1 is the designated name. Type managed means it is client that connects to AP.
ifindex 4 means is as per connected port.

Step 2: Check Device Status

To check if the wireless device is up or not, we use the following command.

# ip link show wlan0

The output show us Wlan0 as up and wlan1  as down.

Step 3: Bring up the wifi interface

Use the following command

# sudo ip  link set wlan0 up

Step 4: Check connection status

Use the following command to check connection status

# iw wlan0 link

To find all WIFI networks detected, type the following command on the terminal.

# iw wlan0 scan

Step 5: Generate WPA/WPA2 config file

Now generate config file for wpa-supplicant that contains pre-shared key for all wifi network

$ sudo vim /etc/wpa_supplicant.conf
wpa_passphrase SSID_name 

Step 6: Connect to WPA/WPA2 wifi network

Use wpa_supplicant command to connect to wifi network:

# wpa_supplicant -B -D wext -i wla0 -C /etc/wpa_supplicant.conf
  • -D specifies the wireless driver wext generic driver.
  • -C gives the actual path of config file
  • -B runs the wpa_supplicant on the background.

Step 7: Get IP address fro DHCP server

Request for IP Address on the interface:

# dhclient wlan0

Verify IP address with the ifconfig command.

# ifconfig -a

Step 8:  Add default routing rule

Add default routing rule to make sure you have correct routing rules:

# ip route show default via dev wlan0 dev wlan0 proto kernel scope link src

Step  9: Test the connectivity

Try ping to any IP address global like google DNS servers


Search Tags:

  • Wifi connectivity with Terminal in Linux
  • How to connect to WIfi in Linux easily
  • Using Terminal to connect to WPA wireless network

Top Cyber Security Learning Video Courses:

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


  1. This post is really informative to all kind of people. I am very happy to see the post. I will request you to give more information about this. I have gotten many knowledgably speech form here. I have also website where you can get some knowledge which may be for your welfare. Visit here…..
    wireless network


Please enter your comment!
Please enter your name here