iwconfig, iwlist, rfkill, wpa_cli, wpa_supplicant, wpa_passphrase, iwgetid, iwspy, iwpriv, iwevent
The classic Linux Wi-Fi toolbox: iwconfig/iwlist and friends (iwgetid, iwspy, iwpriv, iwevent) are the old Wireless Extensions tools now replaced by iw, rfkill turns radios on and off, and wpa_passphrase, wpa_supplicant and wpa_cli do the actual WPA2 login. Knowing which layer each tool touches is key to debugging Wi-Fi on a headless server.
180.1 What it does, where it runs
| Tool | Job | Debian package |
|---|---|---|
| iwconfig, iwlist, iwgetid, iwspy, iwpriv, iwevent | Wireless Extensions: show/set ESSID, mode, channel (legacy, new = iw) | wireless-tools |
| rfkill | Soft / hard block of Wi-Fi, Bluetooth... | rfkill (util-linux) |
| wpa_supplicant + wpa_cli | WPA2 login daemon + its control tool | wpasupplicant |
- All Linux only. Lab: Debian 12 container on a Docker VM with no Wi-Fi radio (CONFIG_CFG80211=m, not loaded; only lo and eth0), so real outputs are the 'no wireless' answers; device examples come from the Arch Wiki, w1.fi and man pages.
- Step 1
1.1 Radio: rfkill list / unblock (Soft blocked: no)
- Step 2
2.2 Driver (Wireless Extensions): iwconfig, iwlist, iwgetid
- Step 3
3.3 WPA: wpa_supplicant does the 4-way handshake with AP LabNet
- Step 4
4.wpa_cli asks status over the control socket: wpa_state=COMPLETED
- Step 5
5.4 IP: dhclient wlan0 -> DHCP from router 192.168.1.1
180.2 iwconfig: display and general
iwconfigiwconfig eth0iwconfig --versionlo no wireless extensions. eth0 no wireless extensions.eth0 no wireless extensions.iwconfig Wireless-Tools version 30 Compatible with Wireless Extension v11 to v22. Kernel Currently compiled with Wireless Extension v22.- No argument = every interface; wired ones say no wireless extensions.
- --help lists: essid, mode, freq, channel, rate, key, power, txpower, retry, modulation and commit (apply pending changes now).
180.3 iwconfig: settings
| Group | Examples | Notes |
|---|---|---|
| Identity | essid "My Network" · essid any · ap 00:60:1D:01:23:45 · nickname | nwid is only for pre-802.11 hardware |
| Mode | Managed · Ad-Hoc · Master · Repeater · Secondary · Monitor · Auto | Managed = AP client; Master = card is the AP; Monitor = passive capture |
| Radio | freq 2.422G · channel 3 · rate 11M|auto · txpower 15 | 30mW | off · rts 250 · frag 512 · modu 11g · sens -80 | txpower off switches the radio off |
| Retry | retry 16 · retry lifetime 300m · retry short 12 · retry min limit 8 | How often / how long to retry a lost frame |
| WEP | key 0123-4567-89 · key s:password [2] · key open|restricted|off | WEP is broken; iwconfig cannot do WPA2/WPA3 |
| Power | power period 2 · power timeout 300u all · power off | Laptop keeps dropping Wi-Fi? power off is the first fix |
180.4 iwlist
iwlist eth0 scanningiwlist eth0 frequencyiwlist lo rateeth0 Interface doesn't support scanning.eth0 no frequency information.lo no bit-rate information.- scanning (root) lists APs; scanning essid X finds a hidden network; scanning last shows old results without a new scan.
- Other options: frequency/channel, rate, keys, power, txpower, retry, event, auth, wpakeys, genie, modulation; ap/peers is deprecated; no interface = all interfaces.
180.5 rfkill: radio on/off
rfkill --versionrfkill listrfkill from util-linux 2.38.1rfkill: cannot open /dev/rfkill: No such file or directory$ rfkill (example from the Arch Wiki)ID TYPE DEVICE SOFT HARD 0 bluetooth hci0 unblocked unblocked 1 wlan phy0 unblocked unblocked# rfkill unblock wlan| Command / option | Effect |
|---|---|
| rfkill list [wifi] / rfkill | Show state (old / table format) |
| rfkill block wlan / block all | Soft block / airplane mode |
| rfkill unblock wifi / unblock 0 | Remove soft block (by type or ID) |
| rfkill toggle bluetooth / event | Flip state / print changes live |
| -J / -n / -o / -r | JSON / no headings / columns / raw |
- Soft block = software, fixed with rfkill unblock; hard block = physical switch or BIOS, rfkill cannot remove it.
- Types: wlan, bluetooth, uwb, wimax, wwan, gps, fm, nfc.
180.6 wpa_passphrase
wpa_passphrase "LabNet" "lab-passphrase"echo "lab-passphrase" | wpa_passphrase LabNetwpa_passphrase "LabNet" "short"network={ ssid="LabNet" #psk="lab-passphrase" psk=f1186863a70a24b215a327a12be11620e3fefd4139da934f01dc99e6db43aab1}# reading passphrase from stdin...Passphrase must be 8..63 characters- Computes the 256-bit PSK offline from SSID + password and prints a ready network block.
- Delete the #psk= comment line before saving: it holds the plain password.
- Reading the password from stdin keeps it out of shell history; it must be 8..63 characters.
180.7 wpa_supplicant
wpa_supplicant -vwpa_supplicant -hwpa_supplicant v2.10drivers: nl80211 = Linux nl80211/cfg80211 wext = Linux wireless extensions (generic) wired = Wired Ethernet driver macsec_linux = MACsec Ethernet driver for Linux none = no driver (RADIUS server/WPS ER)options: -D = driver name (can be multiple drivers: nl80211,wext)example: wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf# wpa_supplicant -B -i interface -c /etc/wpa_supplicant/wpa_supplicant.conf# wpa_supplicant -B -i interface -c <(wpa_passphrase MYSSID passphrase)| Option | Meaning |
|---|---|
| -D nl80211|wext|wired | Driver backend: nl80211 modern, wext old, wired = 802.1X on Ethernet (roboswitch/bsd/ndis not in this build) |
| -i wlan0 / -c file.conf | Interface / config file (the two that matter most) |
| -C dir / -g path / -u | Control socket dir / global control socket / D-Bus |
| -N / -b br0 / -p params | Next interface group / bridge / driver params |
| -B / -P pidfile | Run in background / PID file |
| -d / -dd / -t / -f file / -s | Debug, very verbose, timestamps, log file, syslog |
| -K | Also logs keys: never share such logs |
180.8 wpa_cli
wpa_cli -vwpa_cli statuswpa_cli v2.10Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directorywpa_cli> scan> scan_results> add_network> set_network 0 ssid "MYSSID"> set_network 0 psk "passphrase"> enable_network 0> save_config> quitbssid / frequency / signal level / flags / ssid00:00:00:00:00:00 2462 -49 [WPA2-PSK-CCMP][ESS] MYSSID11:11:11:11:11:11 2437 -64 [WPA2-PSK-CCMP][ESS] ANOTHERSSID<2>CTRL-EVENT-CONNECTED - Connection to 00:00:00:00:00:00 completed (reauth) [id=0 id_str=]STATUS (w1.fi ctrl_iface docs)ssid=test networkkey_mgmt=WPA-PSKwpa_state=COMPLETEDip_address=192.168.1.21suppPortStatus=Authorized- wpa_cli talks to a running wpa_supplicant over the control socket; no daemon = Failed to connect.
- Args: -i interface, -p socket path (default /var/run/wpa_supplicant), -a action file, -B background; no command = interactive prompt.
- Other commands: reconfigure (reread config), reassociate, list_networks, logon/logoff, identity/password/pin/otp (enterprise creds), bssid, terminate.
180.9 iwgetid, iwspy, iwpriv, iwevent
| Tool | Use | Lab output |
|---|---|---|
| iwgetid [--raw|--ap|--freq|--channel|--mode] | Current ESSID for scripts; --raw gives the bare value | (exit 255) |
| iwspy wlan0 IP|name|MAC [setthr 20 40] | Signal/noise of up to 8 nodes (Ad-Hoc) | Interface doesn't support wireless statistic collection |
| iwpriv wlan0 [cmd] [--all] | Driver-private commands (e.g. setqualthr, gethisto) | no private ioctls. |
| iwevent | Live wireless events until Ctrl+C: setting change, new AP, Tx packet dropped, registered/expired node | Waiting for Wireless Events from interfaces... |
- Step 1
1.rfkill list; rfkill unblock wifi if soft blocked
- Step 2
2.wpa_passphrase SSID > conf (remove the #psk line)
- Step 3
3.wpa_supplicant -B -i wlan0 -c conf: 4-way handshake
- Step 4
4.dhclient wlan0: IP from DHCP
- Step 5
5.wpa_cli status: wpa_state=COMPLETED
180.10 Common mistakes
- Using iwconfig essid to join a WPA2 network: it only sets the name and WEP key; the AP rejects it.
- wpa_state stuck at 4WAY_HANDSHAKE: SSID found and associated, but the password/PSK is wrong.
- Trying rfkill unblock on a hard block: flip the physical switch or BIOS setting.
- Sharing -K or -dd logs, or leaving #psk= in the config.
180.11 Interview tips
- Headless WPA2: rfkill list, wpa_passphrase > conf, wpa_supplicant -B -i wlan0 -c conf, DHCP, wpa_cli status = COMPLETED.
- Wireless Extensions (iwconfig) are legacy; nl80211 (iw, wpa_supplicant -Dnl80211) is modern.
- Soft vs hard block: software toggle vs physical switch.
- Stuck at 4-way handshake = wrong key; stuck at scanning/associating = signal or SSID problem.