Hidden from the casual Mac user is a spiffy command line utility that allows you to view, configure, and troubleshoot your Mac’s wireless connection, entirely from the Terminal of MacOS and Mac OS X. This command has a help file but is otherwise but not much documentation, and judging by the obscure location of the command, Apple probably didn’t think it would be too useful for the average Mac user. But the hidden command line airport tool is very useful indeed, particularly for more advanced Mac users who want to have full control over their wi-fi hardware directly from the command line in Mac OS X.

With that in mind, here is how to access the amazingly useful yet little-known airport tool, and how you can use it for some networking tasks too.

How to Access & Use airport Command Line Tool on Mac OS

In case you were wondering, yes the command line airport tool exists in nearly all versions of Mac OS X, even modern versions that stopped calling wireless networking ‘airport’ and refer to it as Wi-Fi. OK let’s begin.

First, Get Easier Access to airport Wi-Fi Tool

The first thing you’ll want to do is create a symbolic link to the airport command, because it is situated in a very inconvenient location with a deep path, this helps for quick usage. Creating a symbolic link to airport is very easy, in the Terminal type the following:

For MacOS Mojave, Catalina, and newer MacOS releases

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

For Mac OS X High Sierra, Sierra, El Capitan, Mavericks, and earlier

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

The above may be a bit hard to read on some browsers, so alternatively you can use the following (it does the same thing, just split into two commands):

For Mac OS Catalina, Mojave, and newer macOS versions

$ cd /usr/local/bin/

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

For Mac OS X High Sierra, Sierra, El Capitan, Mavericks, and earlier

$ cd /usr/sbin

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

Note the only difference between modern macOS versions and prior versions is where you will be placing the symbolic link, which is in /usr/local/bin/ versus in /usr/sbin/

Whichever method you go with, the sudo command will prompt you for a root password, enter it and hit return.

Yes, that giant cryptic path through the depths of Mac OS X is where Apple hid the wonderful airport utility, but by running the above command you have just linked that long path to the much shorter ‘airport’ , which is great.

Using the airport Wireless Tool in Mac OS X Command Line

Now that you have quick and easy access to airport with the above symbolic link, you can start using the airport tool.

For starters, you’ll probably find the -I flag and -s flags to be most useful and informative.

For example, with airport -s you will effectively have a wi-fi router stumbler and get a list of available wireless networks complete with their SSID, BSSID hardware address, security encryption type, and channel.

airport -s

You can also use airport -I at the Terminal prompt, which will return information specific to the current wi-fi connection, looking something like the following:

$ airport -I

commQuality: 75

rawQuality: 59

avgSignalLevel: -40

avgNoiseLevel: -97

linkStatus: ESS

portType: Client

lastTxRate: 11

maxRate: 11

lastAssocStatus: 1

BSSID: 00:06:5b:2a:37:10

SSID: OSXNetwork

Security: none

$

Displayed is detailed information on wireless signal quality, noise, security, and other WiFi network attributes.

The airport command is more powerful than just being able to list information on the current wireless network though, you can actually manually adjust any wi-fi settings, network card settings, troubleshoot networks, change security types used on a connection, capture packets into a pcap file, join and leae networks, disassociate from a wifi network, prioritize routers and networks, see signal strength and interference, adjust wi-fi hardware drivers, and perform a huge variety of network troubleshooting functions too. This is easily one of the most powerful ways to interact with a wireless card on a Mac.

While there is no manual page for the airport command, attaching the -h or –help flag to the command to will issue a brief list of flags and explanations of their function. You can also just run ‘airport’ at the Mac OS X command line to get the full help file, shown below:

$ airport

Usage: airport [interface] [verb] [options] [interface]

If an interface is not specified, airport will use the first AirPort interface on the system. [verb is one of the following:

prefs If specified with no key value pairs, displays a subset of AirPort preferences for

the specified interface. Preferences may be configured using key=value syntax. Keys and possible values are specified below.

Boolean settings may be configured using ‘YES’ and ‘NO’. DisconnectOnLogout (Boolean)

JoinMode (String)

Automatic

Preferred

Ranked

Recent

Strongest

JoinModeFallback (String)

Prompt

JoinOpen

KeepLooking

DoNothing

RememberRecentNetworks (Boolean)

RequireAdmin (Boolean)

RequireAdminIBSS (Boolean)

RequireAdminNetworkChange (Boolean)

RequireAdminPowerToggle (Boolean)

WoWEnabled (Boolean) logger Monitor the driver’s logging facility. sniff If a channel number is specified, airportd will attempt to configure the interface

to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.

Requires super user privileges. debug Enable debug logging. A debug log setting may be enabled by prefixing it with a ‘+’, and disabled

by prefixing it with a ‘-‘. AirPort Userland Debug Flags

DriverDiscovery

DriverEvent

Info

SystemConfiguration

UserEvent

PreferredNetworks

AutoJoin

IPC

Scan

802.1x

Assoc

Keychain

RSNAuth

WoW

P2P

Roam

BTCoex

AllUserland – Enable/Disable all userland debug flags AirPort Driver Common Flags

DriverInfo

DriverError

DriverWPA

DriverScan

AllDriver – Enable/Disable all driver debug flags AirPort Driver Vendor Flags

VendorAssoc

VendorConnection

AllVendor – Enable/Disable all vendor debug flags AirPort Global Flags

LogFile – Save all AirPort logs to /var/log/wifi.log [options] is one of the following:

No options currently defined. Examples: Configuring preferences (requires admin privileges)

sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES Sniffing on channel 1:

airport en1 sniff 1 LEGACY COMMANDS:

Supported arguments:

-c[[arg]] –channel=[[arg]] Set arbitrary channel on the card

-z –disassociate Disassociate from any network

-I –getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.

-s[[arg]] –scan=[[arg]] Perform a wireless broadcast scan.

Will perform a directed scan if the optional [arg] is provided

-x –xml Print info as XML

-P –psk Create PSK from specified pass phrase and SSID.

The following additional arguments must be specified with this command:

–password=[arg] Specify a WPA password

–ssid=[arg] Specify SSID when creating a PSK

-h –help Show this help

As you can see, there is an abundance of options to interact with wireless networks by using the airport utility in Mac OS X. Advanced Mac users should really get a kick out of this one, as it’s extremely powerful, and wildly useful.

You can also do some pretty interesting things with airport, for example this will list available wi-fi routers by name only that are nearby, sorted by signal strength (thanks to @jacobiun for this) but omitting BSSID and other data:

airport -s | tail -n +1 | sed 's/ [a-z0-9][a-z0-9]:/,&:/g' | sed 's/ -/, -/g' | cut -d ',' -f1,3 | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' | grep -v "SSID" | sed 's/ /,/g' | cut -d ',' -f1,2 | sort -t ',' -k 2

The next time you’re working on any wi-fi related task or wireless networking in general, remember the awesome airport tool.