What is the terminal command to turn Airplane Mode on/off in Ubuntu?

Is it simply sudo rfkill block all and sudo rfkill unblock all? I know that this will disable all wireless modules in the computer, but will this be noticed by the system, so that Airplane Mode is toggled off/on in network settings?

  • Try sudo rfkill unblock wifi – Mitch Sep 21 '13 at 9:57
  • @Mitch Do we really need root privileges to climb in an airplane? – Radu Rădeanu Sep 21 '13 at 10:54
  • @RaduRădeanu With all the security issues at airports sure :) lol – Mitch Sep 21 '13 at 11:18

Running the following command in terminal:

gnome-control-center network

will open a window for network management which should be similar with:

Airplane mode on

You can observe that at this moment the "Airplane Mode" is off and the wireless is on.

Now, without to close this window, run the following command in terminal:

nmcli nm wifi off

The above window will be changed automatically to:

Airplane mode on

As you can see, now "Airplane Mode" is on and the wireless is off.

Running, again in terminal, the following command:

nmcli nm wifi off

will turn "Airplane Mode" off and wireless on again.

So, you don't need rfkill (which need also root privileges) to toggle "Airplane Mode" via terminal.

nmcli (see also man nmcli) it's enough and can be executed by any usual user... You don't need root privileges to climb in an airplane :)).

  • nmcli nm wifi off does not turn off airplane mode unless bluetooth is off. – kzh Dec 28 '14 at 17:27
  • 1
    For 15.04 it would be: nmcli r all off and nmcli r all on. Or to include bluetooth: rfkill block bluetooth & rfkill block wlan and rfkill unblock bluetooth & rfkill unblock wlan . – VRR Jul 26 '15 at 12:42
  • For 15.04 (with updates) I found this to work best: alias wifitoggle='nmcli r wifi off ; sleep 1 ; nmcli r wifi on' – Alan Thompson Oct 20 '15 at 23:51
  • Thank you! I was having the same problem. Turns out my laptop was in "flight" mode, but the light indicator wasn't lit... – Salim Ibrogimov Oct 15 at 8:48

For Ubuntu 18.04:

nmcli r wifi on turns airplane mode off, and the converse is true.

A simple bash script to toggle airplane mode on or off is below; save it to file and set its execute bit in properties.

wifi="$(nmcli r wifi | awk 'FNR = 2 {print $1}')
if [ "$wifi" == "enabled" ]`
    nmcli r wifi off
    nmcli r wifi on

On Debian- and Arch-based distros, inspired by the previous code, this will disable WiFi and Bluetooth and send a notification:

wifi="$(nmcli r wifi | awk 'FNR = 2 {print $1}')"
if [ "$wifi" == "enabled" ]; then
    rfkill block all &
    notify-send 'Mode avion: actif'
    rfkill unblock all &
    notify-send 'Mode avion: inactif'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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