How To Configure Linux Wireless From Command Line with wpa_supplicant
wpa_supplicant is used to connect wireless networks.
wpa_supplicant.conf file is used to store related configuration file about the wireless network. Also wireless security policy is configured with this file.
Install wpa_supplicant Package
In most of cases the
wpa_supplicant package is installed by default but we can use following commands in order to install this package.
Fedora, RHEL, CentOS
$ sudo yum install wpa_supplicant
Ubuntu, Debian, Mint, Kali
$ sudo apt install wpa_supplicant
More detailed help information can be show with
-h option like below.
$ wpa_supplicant -h
Specify Interface and Configuration File
The most basic and used way to run
wpa_supplicant is providing the interface name and the configuration file. We can use
-i to specify interface and
-c for configuration file like below.
$ wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Run Daemon In Background
The deafult behaivour of
wpa_supplicant is running on foregound which will take terminal busy. This will also create the stability problems where closing terminal will kill network connection too. We can use
-B option for background connection.
$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Sample Wireless Configuration
Here is a sample configuration which has SSID name
poftut and key management is specified as
psk="very se+ret passphrase"