Making airplane mode the default on startup

I installed Ubuntu 25.04 as my first linux experience on my home/family machine. I want the computer to boot in airplane mode. A google search suggests entering the following on the terminal:
$ sudo apt update
$ sudo apt install rfkill
$ nano ~/.profile
rfkill block wlan bluetooth

I haven’t attempted this yet since I want to still use the airplane icon to turn WiFi and Bluetooth on. Does the above allow use of that icon? What would be the code to reverse the above?

1 Like

Lets start here, Adding the following command to ~/.profile will block wireless radio sources when you boot and log on:

rfkill block wlan bluetooth

This command will take effect every time you log onto your session.

You can also create a systemd service to block wireless radio sources regardless of whether you have logged on. This service can even be set up to repeat the command at intervals to prevent users from enabling wireless connections.

One possibility for that is something along the way of:

For example, you can create a file named /etc/systemd/system/rfkill-block-wifi.service with the following content:

[Unit]
Description=Block Wireless Radio
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/rfkill block wifi
RemainAfterExit=true

Enable the service to start at boot:

sudo systemctl enable rfkill-block-wifi.service

Start the service immediately:

sudo systemctl start rfkill-block-wifi.service

This will ensure that the wireless radio is blocked at boot time and remains blocked until manually unblocked. If you need to unblock the wireless radio later, you can use the command sudo rfkill unblock wifi. Or (all)

``` rfkill list
0: ideapad_wlan: Wireless LAN
	Soft blocked: yes
	Hard blocked: no
1: ideapad_bluetooth: Bluetooth
	Soft blocked: yes
	Hard blocked: no
2: phy0: Wireless LAN
	Soft blocked: yes
	Hard blocked: no
3: hci0: Bluetooth
	Soft blocked: yes
	Hard blocked: no
4: hci1: Bluetooth
	Soft blocked: yes
	Hard blocked: no

sudo rfkill unblock all
[sudo] password for me:
┌───────────────────>
│~
└─> rfkill list
0: ideapad_wlan: Wireless LAN
Soft blocked: no
Hard blocked: no
1: ideapad_bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
2: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
3: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
4: hci1: Bluetooth
Soft blocked: no
Hard blocked: no

2 Likes

I’d not do it on such a low level but instead use the startup applications function of GNOME and add something like below…

gdbus call --session --dest org.gnome.SettingsDaemon.Rfkill --object-path /org/gnome/SettingsDaemon/Rfkill --method org.freedesktop.DBus.Properties.Set 'org.gnome.SettingsDaemon.Rfkill' 'AirplaneMode' '<true>'

That makes sure your script uses the exact same mechanism the GUI toggle uses, so you are safe from things going possibly out of sync (while the low level call of rfkill will likely work, doing it on the same high level as the GUI switch simply prevents you from hitting possible non detected bugs here)

1 Like

This must be a Gnome only suggestion, and that’s Ok, but on xfce:

gdbus call --session --dest org.gnome.SettingsDaemon.Rfkill --object-path /org/gnome/SettingsDaemon/Rfkill --method org.freedesktop.DBus.Properties.Set 'org.gnome.SettingsDaemon.Rfkill' 'AirplaneMode' '<true>'
Error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SettingsDaemon.Rfkill was not provided by any .service files

:wink:

Indeed, since the OP talked about a standard Ubuntu install I was assuming GNOME … not sure how xfce deals with it on the GUI level (though I’d expect some kind of dbus helper there too)

You seem to be on a dbus kick lately. :slight_smile:

You force me to study this at a different view point…LOL :+1:

Well, if you want to do any fake-GUI stuff in scripts without having to involve sudo, dbus is the way to go …

To the OP, I’m replying more as a general suggestion for all DE’s.
My previous suggestion is good for myself at a lower level, but @ogra got me to think, and it’s early still for me, but this also works on All DE’s.
Bus:

busctl tree org.bluez
└─ /org
  └─ /org/bluez
    ├─ /org/bluez/hci0
    └─ /org/bluez/hci1
      └─ /org/bluez/hci1/dev_F8_DF_15_7F_64_73
        └─ /org/bluez/hci1/dev_F8_DF_15_7F_64_73/sep1
          └─ /org/bluez/hci1/dev_F8_DF_15_7F_64_73/sep1/fd

You can also create a custom script to toggle airplane mode. Here is an example script:

#!/bin/bash

if nmcli radio wifi | grep -q "enabled"; then
    nmcli radio wifi off
    nmcli radio bluetooth off
    notify-send "Airplane Mode" "Enabled"
else
    nmcli radio wifi on
    nmcli radio bluetooth on
    notify-send "Airplane Mode" "Disabled"
fi

Save this script to a file, for example, toggle_airplane_mode.sh.
Make the script executable:

chmod +x toggle_airplane_mode.sh

You can then run this script to toggle airplane mode:

./toggle_airplane_mode.sh

Adding a Custom Panel Plugin:
If you want a more integrated solution, you can create a custom panel plugin for XFCE4 that toggles airplane mode. This involves writing a small C program or using a scripting language like Python to interact with the Network Manager.

I use as a alias !
So many choices…LOL

Part of the beauty of linux is choice, and not locked in to a point of view by a specific Distro

Mine is still good and changes on the contorler settings.
Screenshot From 2025-05-07 09-26-30