Find Detailed Wi-Fi Connection History from Command Line of Mac OS X

Jun 3, 2015 - 5 Comments

Finding extensive wi-fi connection history in Mac OS X

There are some situations where knowing exactly what wireless networks a Mac has connected to and when that connection was last established can be helpful. We’ll demonstrate how to uncover a comprehensive listing of specifics about previously joined wi-fi networks, which will include the last connection date and time (to the second!), if the network is hidden or not, the network SSID number, the networks SSID broadcast name, and the security type of each wifi network.

This will use the command line of OS X, which is obviously a bit more advanced and perhaps not applicable to average Mac users. Nonetheless, the retrieved information can be helpful for a wide variety of purposes. You’ll find the data useful for something as simple as recovering a forgotten a wi-fi network password from a router which you can’t quite remember the name of, to network troubleshooting and diagnostics, or even for data analysis and forensic purposes.

Launch the Terminal application, located in /Applications/Utilities/ (or with Spotlight and Command+Spacebar) and enter the following command string into a single line:

For modern versions of Mac OS X, OS X Yosemite 10.10 and newer, use the following:

defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences |grep LastConnected -A 7

For OS X Mavericks and earlier versions of Mac OS X, you can use the following command to clean up the output and match that which is available in modern releases:

defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences| sed 's|\./|`pwd`/|g' | sed 's|.plist||g'|grep 'LastConnected' -A 7

Hit return and you’ll instantly see the comprehensive listing of wireless network connection details.

Here’s an example of output supplied by this command string, showing three connected networks.

$ defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences |grep LastConnected -A 7
LastConnected = "2015-05-29 09:14:48 +0000";
Passpoint = 0;
PossiblyHiddenNetwork = 0;
RoamingProfileType = Single;
SPRoaming = 0;
SSID = <455c1211 75717d41 984c8712 474482>;
SSIDString = "HomeWirelessWAN-ng";
SecurityType = "WPA/WPA2 Personal";
--
LastConnected = "2015-05-31 01:52:43 +0000";
Passpoint = 0;
PossiblyHiddenNetwork = 1;
RoamingProfileType = Single;
SPRoaming = 0;
SSID = <75891725 8382b4b 409f8581 85264891 1212c6c5 74713871>;
SSIDString = "Secret Network 1";
SecurityType = "WPA2 Personal";
--
LastConnected = "2015-06-03 08:32:12 +0000";
Passpoint = 0;
PossiblyHiddenNetwork = 0;
RoamingProfileType = Single;
SPRoaming = 0;
SSID = <65428519 94198bc1 142848b1 847b564b 9852719c>;
SSIDString = "Public Network - Parks 1";
SecurityType = "None";

Keep in mind if you run this command on a Mac that has joined many wireless routers, you’ll find a very lengthy list returned, which may be better read if redirected into a text file by appending “> ~/Desktop/connectionlist.txt” to the end of the syntax like so:

defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences |grep LastConnected -A 7 > ~/Desktop/connectionlist.txt

If you use that command, a file named ‘connectionlist.txt’ will appear on the current users OS X desktop with the pertinent information.

Retrieve detailed wireless connection history details from Mac OS X command line

Regular readers here may recall that we have shown a few ways to find which wi-fi networks a Mac has connected to before, but those methods in comparison provide notably less information, certainly compared to the extensive details offered here. You can use whichever is most relevant to your needs.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

5 Comments

» Comments RSS Feed

  1. John says:

    We need to take this a step further. How can we block certain wireless networks (read: infinitywifi, et. al.)?
    When I ‘forget this network’, iCloud puts it right back in the list.
    I asked during a genius bar appointment and they had me delete a directory that removed all network information. Then I had to re-connect to my home wifi. After a few minutes, viola! the stupid list was back.
    Thanks iCloud, I hate you

    • INDC says:

      Lol at “Thanks iCloud, I hate you” …let me echo that sentiment. I hope/demand that Apple finally gets iCloud right in these upcoming software versions, rather than the colossal pain/waste/disaster it currently is.

  2. Wow, still have my wallpaper on. I am honored!

  3. John S says:

    Is there an update for this command line for El Capitan? I get a directory not found reply.

    Thanks,
    John

    • Pal says:

      The command works to show wi-fi history in Sierra and El Capitan:

      defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences |grep LastConnected -A 7

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates