how to create a wireless connection on linux

From Wikipedia:

wpa_supplicant is a free software implementation of an IEEE 802.11i supplicant for Linux , FreeBSD , NetBSD , QNX , AROS , Microsoft Windows , Solaris , OS/2 (including eComStation ) and Haiku.
In addition to being a fully featured WPA2 supplicant , it also implements WPA and older wireless LAN security protocols.

With this in mind we are now going to create a new configuration to access internet.
Obviously these steps must be processed from a terminal.

Let's check first your hardwares:

$ sudo lshw -C network

Next you have to select the access point to reach a connection:

$ sudo iwconfig

Now you may see two or more access points that you can connect to, like this:

Image description

Note from the image that only "wlan0mon" wireless interface is available to allow you connect to internet, which is the hardware on your laptop or pc.

Next, you have to search and recognize all the wireless connections available close to you. It's time to listing them:

$ sudo iwlist wlan0mon scan | grep ESSID

Once you have localized the name of the connection, you can now configuring its settings with wpa_passphrase:

$ sudo wpa_passphrase "<name of connection>" "<password>" > /etc/wpa_supplicant/wpa.conf

Now if you want to check the details that wpa_passphrase has created:

$ sudo cat /etc/wpa_supplicant/wpa.conf

You will see the details you have just inserted previously:

Image description

It's time to get into the final process by set a connection via wpa_supplicant namely the software you have just seen above.
Let's try out how to do that. First go take a look at what wpa_supplicant provide to the user:

$ sudo wpa_supplicant

The output will just like this:

Image description

$ sudo wpa_supplicant -Dnl80211,wext -iwlan0mon -c /etc/wpa_supplicant/wpa.conf -B

Now if you want to see if your hardware is succesfully connected to internet, first go take a look to your access point:

$ sudo iwconfig

At second you may want to detect a check through a ping.

$ ping www.google.com
Image description

WHAT IF WPA_SUPPLICANT THROWS ERRORS?

There is a common problem that wpa_supplicant goes to, it is when there is another process running on the background, so when you want to connect it sais that is not possible.
Knowing the cause of this problem, let's see first if there are really some other processes running:

$ sudo pgrep wpa_supplicant

This command will generates an output of a series of digits, these are the processess.
To kill them so to allow you get a clean connection without errors, launch this command:

$ sudo killall wpa_supplicant

Now you can go back and set your own connection with wpa_supplicant.

linux wifi wpa connection wireless