Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This question is an exact duplicate of this post from superuser.exchange.com. I believe this is a valid question for both of sites and hope I am not (if any) violating stackexchange policies.

Mac OS X doesn't recognize rfkill from its terminal, and I am looking for an alternative command that has similar functionality (toggling "Airplane Mode").

NOTE: I don't wish to open an .app to toggle. I'd like to execute the command from command line or within script in Bash (or equivalents).

By "Airplane Mode", I meant to borrow the term from iOS support page here. I would like to disable all incoming/outgoing network communications from my system.

share|improve this question
add comment

2 Answers

Make an ad hoc location named isolated or airplane where all the network interfaces are present and turned off.

Switch to this deaf location with:

networksetup -switchtolocation isolated

It might be more interesting than rfkill since you can protect you from an unnoticed Ethernet cable which might be listening to all your communications (and they are a lot) :[. To check that everything is really off, run:

ifconfig -a | grep '[<,]UP[,>]' | grep -v '[<,]LOOPBACK[,>]'

If this command doesn't display anything, then all your interfaces are down, everything is OK.

If this command output anything, as here:


then it means that the interface name (here en1 which is the wireless one on this Mac) is on where it shouldn't. This is the sign that either the configuration made is failing or that some Trojan horse turned it on to reach its control server via the Internet.

share|improve this answer
add comment

Depending on my objective (Should I concern about shutting down data interface as well?), I can choose the plan accordingly:

Plan A for (1) Network Interfaces and (2) Data Interface

Plan B for (1) Network Interfaces

(Plan A #1) Get installed hardware interfaces info (including data interfaces):

First, I'd like to know how many and what types of interfaces I should worry about.

$ networksetup -listallhardwareports

Hardware Port: Bluetooth DUN
Device: Bluetooth-Modem
Ethernet Address: N/A

Hardware Port: Ethernet
Device: en0
Ethernet Address: ff:ff:ff:ff:ff:ff

Hardware Port: FireWire
Device: fw0
Ethernet Address: ff:ff:ff:ff:ff:ff:ff:ff

Hardware Port: Wi-Fi
Device: en1
Ethernet Address: ff:ff:ff:ff:ff:f

(Plan A #?) (Optional) Get the list of network interfaces only:

This step makes me easy to grep.

$ networksetup -listallnetworkservices

An asterisk (*) denotes that a network service is disabled.

(Plan A #2) Get the device name of the network interfaces.

I'd like to know which network interface(s) is/are active.

$ ifconfig

    ether ff:ff:ff:ff:ff:ff 
    media: autoselect (none)
    status: inactive
    ether ff:ff:ff:ff:ff:ff 
    inet6 ffff::ffff:ffff:ffff:ffff%en1 prefixlen 64 scopeid 0x5 
    inet 192.168.1.fff netmask 0xffffff00 broadcast 192.168.1.fff
    media: autoselect
    status: active
    lladdr ff:ff:ff:ff:ff:ff:ff:ff 
    media: autoselect <full-duplex>
    status: inactive

(Plan B #1) Locate airport command or set alias for airport command if not recognized:

My system couldn't recognize airport command, so I had to add below line to .bash_profile.

alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport'

(Plan B #2) Check current AirPort status:

$ ./airport -I

     agrCtlRSSI: -10
     agrExtRSSI: 0
    agrCtlNoise: -10
    agrExtNoise: 0
          state: running
        op mode: station 
     lastTxRate: 100
        maxRate: 100
lastAssocStatus: 0
    802.11 auth: open
      link auth: fffffffffffffffff
          BSSID: ff:ff:ff:ff:ff:ff
           SSID: MelvNetwork
            MCS: 15
        channel: 6 

(Plan A & B #3)Turning on/off the AirPort:

# For OS X 10.7 and later
$ networksetup -setairportpower en1 on   # Turn on Airport
$ networksetup -setairportpower en1 off  # Turn off Airport

# for OS X 10.6 and below
$ networksetup -setairportpower on       # Turn on AirPort
$ networksetup -setairportpower off      # Turn off AirPort

(Plan A & B #4)Turning on/off the BlueTooth:

Download blueutil here.

$ blueutil status  # Check status of BlueTooth
Status: on

$ blueutil on      # Turn BlueTooth on

$ blueutil off     # Turn BlueTooth off


Now that I have all the ingredients, I can write the script for OS X 10.7!

Last Comments:

(1) Some of the output are masked with the character 'f'.

(2) According to $ man networksetup, you can configure the proxy, TCP/IP, PPPoE as well (not tested).

(3) @RichHomolka's suggestion, networksetup --enableuserprofile is deprecated for OS X 10.7 (not tested in other versions).

(4) If anyone following the above procedure encounters a problem, could you please address them in the comment (or as in a separate answer)?

share|improve this answer
Welcome to the site and thanks for the analysis. The only piece missing in your answer (and the one thing future visitors will be looking for) is the script combining all the findings into a solution. Could you please add this as well? –  patrix Mar 22 '13 at 5:49
@patrix I haven't finished writing the script yet, and (I think) it may be little long to post here..I am planning to post it on github instead. I'll update the address to the github later. Thanks for your greeting! –  melvkim Mar 22 '13 at 7:32
Hi melv! I've deleted your question on Super User, as verbatim cross posting is definitely not allowed. It would have been fine to stay on either site though, just FYI. –  slhck Mar 22 '13 at 16:00
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.