How can I find Wi-Fi SSID using a terminal command?

How can I find the SSID from the wifi with a cmd in the terminal



[Re-Titled by Moderator]


iMac 24″, macOS 14.6

Posted on Feb 6, 2025 2:14 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 6, 2025 7:40 AM

The following works on my Sequoia v15.3 system to output the SSID using the Zsh shell. It gets a sorted list of the en0 - en9 interfaces and performs an ipconfig getsummary on each. Finally, it finds the SSID (that leading space is deliberate) string in the getsummary output and prints it. Failed matches are discarded to dev/null.


for i in ${(o)$(ifconfig -lX "en[0-9]")};do ipconfig getsummary ${i} | awk '/ SSID/ {print $NF}';done 2> /dev/null



The wdutil info output shows <redacted> for both SSID and BSSID on my system. I am using WPA3 security and that may have something to do with the redaction.


A Zsh script that will also work (once made executable) if one's shell is Bash follows:

#!/bin/zsh

for i in ${(o)$(ifconfig -lX "en[0-9]")};
do 
    ipconfig getsummary ${i} | awk '/ SSID/ {print $NF}'
done 2> /dev/null
exit 0


8 replies

Feb 6, 2025 5:05 AM in response to kaz-k

kaz-k wrote:

You can see it following commands in the Terminal.app.

networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork

What I get…

dialabrain@iMac-M3 ~ % networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}' | xargs networksetup -getairportnetwork

You are not associated with an AirPort network.

Question marked as Top-ranking reply

Feb 6, 2025 7:40 AM in response to rinus228

The following works on my Sequoia v15.3 system to output the SSID using the Zsh shell. It gets a sorted list of the en0 - en9 interfaces and performs an ipconfig getsummary on each. Finally, it finds the SSID (that leading space is deliberate) string in the getsummary output and prints it. Failed matches are discarded to dev/null.


for i in ${(o)$(ifconfig -lX "en[0-9]")};do ipconfig getsummary ${i} | awk '/ SSID/ {print $NF}';done 2> /dev/null



The wdutil info output shows <redacted> for both SSID and BSSID on my system. I am using WPA3 security and that may have something to do with the redaction.


A Zsh script that will also work (once made executable) if one's shell is Bash follows:

#!/bin/zsh

for i in ${(o)$(ifconfig -lX "en[0-9]")};
do 
    ipconfig getsummary ${i} | awk '/ SSID/ {print $NF}'
done 2> /dev/null
exit 0


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I find Wi-Fi SSID using a terminal command?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.