Categories
SysOps

How to display currently connected wireless network

Display the name of the wireless network you are connected to.

iwgetid

Use iwgetid utility to display currently connected wireless network.

$ iwgetid 
wlan0     ESSID:"Searching..."

Display the name of the wireless network you are connected to using specific wireless device.

$ iwgetid --raw wlan0
Searching...

wpa_cli

Use WPA command-line client to inspect available interfaces.

$ wpa_cli interface
Selected interface 'p2p-dev-wlan0'
Available interfaces:
p2p-dev-wlan0
wlan0

Display interface status.

$ wpa_cli -i wlan0 status
bssid=00:78:cd:b1:b3:ea
freq=2437
ssid=Searching...
id=0
mode=station
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
ip_address=192.168.8.159
p2p_device_address=e6:5f:01:e2:3d:40
address=e4:5f:01:e2:3d:40
uuid=cf3bd88c-ba7b-52d2-a85a-29a8a7646161

Evaluate output of the WPA command-line client to use specific data.

$ (eval $(wpa_cli -i wlan0 status); echo $ssid)
Searching...

Use awk to parse output of the WPA command-line client to use specific data.

$ wpa_cli -i wlan0 status | awk -F= '/^ssid/ {print $2}'
Searching...

iw

Use iw utility to display wireless devices.

$ iw dev
phy#0
	Unnamed/non-netdev interface
		wdev 0x2
		addr e6:5f:01:e2:3d:40
		type P2P-device
		txpower 31.00 dBm
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr e4:5f:01:e2:3d:40
		ssid Searching...
		type managed
		channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz
		txpower 31.00 dBm

Get wireless device details.

$ iw dev wlan0 info
Interface wlan0
	ifindex 3
	wdev 0x1
	addr e4:5f:01:e2:3d:40
	ssid Searching...
	type managed
	wiphy 0
	channel 6 (2437 MHz), width: 20 MHz, center1: 2437 MHz
	txpower 31.00 dBm

Get wireless device link information.

$ iw dev wlan0 link
Connected to 00:78:cd:b1:b3:ea (on wlan0)
	SSID: Searching...
	freq: 2437
	RX: 60180 bytes (519 packets)
	TX: 8279 bytes (96 packets)
	signal: -21 dBm
	rx bitrate: 1.0 MBit/s
	tx bitrate: 24.0 MBit/s

	bss flags:	short-preamble short-slot-time
	dtim period:	1
	beacon int:	100

iwconfig

Use iwconfig utility to display wireless devices.

$ iwconfig 
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11  ESSID:"Searching..."  
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:78:cd:b1:b3:ea   
          Bit Rate=24 Mb/s   Tx-Power=31 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-22 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:4  Invalid misc:0   Missed beacon:0

Alternatively, display details for specific wireless device details.

$ iwconfig wlan0
wlan0     IEEE 802.11  ESSID:"Searching..."  
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:78:cd:b1:b3:ea   
          Bit Rate=24 Mb/s   Tx-Power=31 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=70/70  Signal level=-22 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:4  Invalid misc:0   Missed beacon:0