Find & Scan Wireless Networks from the Command Line in Mac OS X

Feb 28, 2012 - 12 Comments

Find and Scan Wi-Fi Networks in OS X Command Line

A long hidden airport command line utility buried deep in Mac OS X can be used to scan for and find available wireless networks. This powerful tool is very helpful for network admins and systems administrators, but it’s handy for the average user to help discover nearby wi-fi routers as well.

Accessing the Wi-Fi Utility in Mac OS X Command Line

To use this tool to find nearby wifi networks, the first thing you’ll want to do is create a symbolic link from the airport utility to /usr/sbin for easy access. The command for this varies per version of Mac OS in use, select which is relevant to your Mac OS X version on the Mac in question.

Launch the Terminal and type the following command:

Making a symbolic link for airport tool in MacOS High Sierra, Sierra, OS X El Capitan, Yosemite, and later
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

If you see an “operation not permitted” error message it’s likely because you either don’t have a bin directory in /usr/local/ (you can make one yourself), or you have SIP enabled, the SIP rootless feature can be disabled if desired by advanced users.

Make a symbolc link for airport tool in Mac OS X Mavericks, Mountain Lion, Snow Leopard

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

Either of the above commands must appear on a single line to work properly.

Enter the administrator password to create the symbolic link, which functions as an alias would in the Finder. Now you can use the airport command without the lengthy path to access it.

How to Scan for Wireless Networks from Terminal in Mac OS X

Now, to scan for and find all wireless networks within range, type the following:

airport -s

The list returned will show all available wifi networks and their router name (SSID), the router address (BSSID), signal strength (RSSI), channel, and security types used by the network.

list wireless networks

This basically works like a command line wi-fi stumbler, revealing the available wireless networks that are within range.

By watching the output of airport -s and the RSSI strength, you could use the airport command line tool in a similar fashion to the Wi-Fi Diagnostics utility to optimize a wireless connection.

You can also get much of the same detailed information from the Wi-Fi menu by holding the Option key on click, although that will only show you details of one access point at a time.

Alternatively, Mac users can turn to the Wi-Fi scanner tool native to Mac OS X to stumble for nearby wireless networks entirely in the GUI. The output will be the same for either the Wireless Diagnostics app approach, or the command line approach offered here.

Do you have any handy tips or tricks for scanning wireless networks from the command line of a Mac? Either using built-in tools or third party options? Share your thoughts in the comments below!


Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. ShadowK says:

    Anyone can tell me what does +1 or -1 means in CHANNEL?

  2. Ashish Pattekar says:

    Alternatively (rather than creating a symbolic link), if you are using the default bash shell you can add the following line in the ~/.bash_profile file (edit using any text editor)

    alias airport=”/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport”

  3. Mike says:

    You can’t simply perform a single check of the signal to noise ratio, or signal strength to determine the best network. The reliability of a network changes over time. You would need to see how many packets dropped over a period of minutes to get a more accurate check.

    I only say this because the command line doesn’t seem to be able to check for dropped packets… so maybe you were assuming signal to noise ratio or signal strength was a good test of network reliability.

  4. Nick says:

    If you’re reading this in 2015/2016 and you’ve now upgraded to El Capitan, you’ll get an error saying “ln: /usr/sbin/airport: Operation not permitted”.
    This is because the target directory should be /usr/local/bin/airport. The following solution works on all Mac versions including El Capitan:
    sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

  5. M San says:

    How do I connect to a wireless network using command line?

  6. King says:

    how can I delete this alias now?

    • W says:

      it’s not an alias, it’s just a symbolic link so that you can type ‘airport’ at the command line rather than a giant path first.

      You can remove the symbolic link by typing:

      sudo rm /usr/sbin/airport

      There is no practical reason to do so, however.

  7. Gordon Gecko says:

    makes you wonder what other cool utilities are hiding in the depths of obscure os x directories…

  8. sL1Per says:

    Nice one!! But id rather create and alias for it!
    alias airport=’/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport -$1′


Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

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

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site