wpa_cli(1)
Command-line interface for interacting with wpa_supplicant wireless authentication daemon.
Synopsis
wpa_cli [-p <path to ctrl sockets>] [-i <iface>] [-h] [-v] [-B] [-a <action script>] [-P <pid file>] [command]Description
wpa_cli is a text-based frontend for interacting with wpa_supplicant, the WPA/WPA2/IEEE 802.11i supplicant implementation for Linux. It communicates with the wpa_supplicant daemon over a local socket to manage wireless network connections, scanning, and authentication.
When run without a command argument, wpa_cli enters interactive mode where you can issue commands at a prompt. This is useful for real-time network management, debugging, and scripting automated network tasks.
Common uses include scanning for networks, adding/removing network profiles, connecting to specific SSIDs, checking connection status, and managing WPS (Wi-Fi Protected Setup).
Common options
| Flag | What it does |
|---|---|
-i <iface> | Specify the wireless interface to control (e.g., wlan0); defaults to first available |
-p <path> | Path to wpa_supplicant control socket directory; usually /var/run/wpa_supplicant |
-B | Run in daemon mode; useful with -a for event monitoring in the background |
-a <script> | Run an action script on wpa_supplicant events (CONNECTED, DISCONNECTED, etc.) |
-P <pidfile> | Write daemon PID to file when used with -B |
-v | Show version information and exit |
-h | Display help message and exit |
Examples
Initiate a WiFi scan to discover available networks on wlan0
wpa_cli -i wlan0 scanDisplay the results of the most recent WiFi scan in BSSID/SSID/level format
wpa_cli -i wlan0 scan_resultsCreate a new network profile and return its numeric ID for configuration
wpa_cli -i wlan0 add_networkSet the SSID for network profile 0; quotes must be escaped in shell
wpa_cli -i wlan0 set_network 0 ssid '"MyNetwork"'Set WPA2 PSK passphrase for network 0 and enable it for connection
wpa_cli -i wlan0 set_network 0 psk '"password123"' && wpa_cli -i wlan0 enable_network 0Display current connection status, IP details, and wpa_state
wpa_cli -i wlan0 statusEnter interactive prompt mode for issuing multiple commands sequentially
wpa_cli -i wlan0Run wpa_cli in daemon mode, executing wpa_event.sh script on network state changes
wpa_cli -i wlan0 -B -a /usr/local/bin/wpa_event.sh