SkillPilotAI

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

ToolJobDebian package
iwconfig, iwlist, iwgetid, iwspy, iwpriv, iweventWireless Extensions: show/set ESSID, mode, channel (legacy, new = iw)wireless-tools
rfkillSoft / hard block of Wi-Fi, Bluetooth...rfkill (util-linux)
wpa_supplicant + wpa_cliWPA2 login daemon + its control toolwpasupplicant
  • 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.
Linux Wi-Fi stack: from radio to IP
  1. 1.1 Radio: rfkill list / unblock (Soft blocked: no)

  2. 2.2 Driver (Wireless Extensions): iwconfig, iwlist, iwgetid

  3. 3.3 WPA: wpa_supplicant does the 4-way handshake with AP LabNet

  4. 4.wpa_cli asks status over the control socket: wpa_state=COMPLETED

  5. 5.4 IP: dhclient wlan0 -> DHCP from router 192.168.1.1

180.2 iwconfig: display and general

Terminal
iwconfigiwconfig eth0iwconfig --version
Output
lo        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

GroupExamplesNotes
Identityessid "My Network" · essid any · ap 00:60:1D:01:23:45 · nicknamenwid is only for pre-802.11 hardware
ModeManaged · Ad-Hoc · Master · Repeater · Secondary · Monitor · AutoManaged = AP client; Master = card is the AP; Monitor = passive capture
Radiofreq 2.422G · channel 3 · rate 11M|auto · txpower 15 | 30mW | off · rts 250 · frag 512 · modu 11g · sens -80txpower off switches the radio off
Retryretry 16 · retry lifetime 300m · retry short 12 · retry min limit 8How often / how long to retry a lost frame
WEPkey 0123-4567-89 · key s:password [2] · key open|restricted|offWEP is broken; iwconfig cannot do WPA2/WPA3
Powerpower period 2 · power timeout 300u all · power offLaptop keeps dropping Wi-Fi? power off is the first fix

180.4 iwlist

Terminal
iwlist eth0 scanningiwlist eth0 frequencyiwlist lo rate
Output
eth0      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

Terminal
rfkill --versionrfkill list
Output
rfkill from util-linux 2.38.1rfkill: cannot open /dev/rfkill: No such file or directory
Output
$ 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 / optionEffect
rfkill list [wifi] / rfkillShow state (old / table format)
rfkill block wlan / block allSoft block / airplane mode
rfkill unblock wifi / unblock 0Remove soft block (by type or ID)
rfkill toggle bluetooth / eventFlip state / print changes live
-J / -n / -o / -rJSON / 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

Terminal
wpa_passphrase "LabNet" "lab-passphrase"echo "lab-passphrase" | wpa_passphrase LabNetwpa_passphrase "LabNet" "short"
Output
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

Terminal
wpa_supplicant -vwpa_supplicant -h
Output
wpa_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
Terminal
# wpa_supplicant -B -i interface -c /etc/wpa_supplicant/wpa_supplicant.conf# wpa_supplicant -B -i interface -c <(wpa_passphrase MYSSID passphrase)
OptionMeaning
-D nl80211|wext|wiredDriver backend: nl80211 modern, wext old, wired = 802.1X on Ethernet (roboswitch/bsd/ndis not in this build)
-i wlan0 / -c file.confInterface / config file (the two that matter most)
-C dir / -g path / -uControl socket dir / global control socket / D-Bus
-N / -b br0 / -p paramsNext interface group / bridge / driver params
-B / -P pidfileRun in background / PID file
-d / -dd / -t / -f file / -sDebug, very verbose, timestamps, log file, syslog
-KAlso logs keys: never share such logs

180.8 wpa_cli

Terminal
wpa_cli -vwpa_cli status
Output
wpa_cli v2.10Failed to connect to non-global ctrl_ifname: (nil)  error: No such file or directory
Terminal
wpa_cli> scan> scan_results> add_network> set_network 0 ssid "MYSSID"> set_network 0 psk "passphrase"> enable_network 0> save_config> quit
Output
bssid / 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

ToolUseLab 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.
iweventLive wireless events until Ctrl+C: setting change, new AP, Tx packet dropped, registered/expired nodeWaiting for Wireless Events from interfaces...
Join WPA2 Wi-Fi from a headless server
  1. 1.rfkill list; rfkill unblock wifi if soft blocked

  2. 2.wpa_passphrase SSID > conf (remove the #psk line)

  3. 3.wpa_supplicant -B -i wlan0 -c conf: 4-way handshake

  4. 4.dhclient wlan0: IP from DHCP

  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.