Q: How do I use the airport command on Mac OS X?
- What is the airport command on Mac OS X?
- Can I control my Mac's wireless card from the command line?
- Can I get information about my Mac's wireless connection from the command line?
Context
- Mac OS X 10.5 and later (and possibly other versions)
- Mac Airport wireless card or built in Wi-Fi
- Command line via Terminal application
- This command requires familiarity with the Mac OS X command line
Answer
Mac OS X (tried on 105 but probably on earlier versions as well) contains a well-hidden command line command for querying and controlling a Mac's Airport card and connection to wireless networks. The command is not well-documented but contains some built-in help. It can be very useful in quickly showing you which specific access point you are connected to, channel numbers, signal strength, and so on.
Location
On 10.5 or later, the command can be found at:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
Basic usage
To get information about your wireless connection, run the command with the option --getinfo or -I:
othomas$ /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --getinfo agrCtlRSSI: -65 agrExtRSSI: 0 agrCtlNoise: -90 agrExtNoise: 0 state: running op mode: station lastTxRate: 108 maxRate: 270 lastAssocStatus: 0 802.11 auth: open link auth: unknown BSSID: 0:21:d8:49:db:fe SSID: MIT N MCS: 11 channel: 161,-1
If you use the command frequently you may want to create a symbolic link to it in your home directory or a directory in your path so you don't have to type the full path name every time.
Advanced usage
You can run the command with the --help or -h argument to get it to show you all available options and arguments. It allows you to associated and disassociate with different wireless networks from the command line, along with a lot of other functionality.
While the risk is low, you do want to be careful if you are not sure what the different options are, as it could cause your Mac to lose its network connection or set up a peer-to-peer wireless network.