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

UPDATE: Making Airplane Mode the Default on Startup

In way of review: I am running Ubuntu 25.04 on an Asus Vivobook (AMD 64). My computer has 3 users with me (admin) having administrator privileges.

Previously asked how to make the airplane mode (both wlan and bluetooth) the default on login. Suggestions largely were along two lines:

1.) Adding terminal command: nano ~/.profile

                                                       rfkill block wlan and bluetooth

2.) creating a GNOME startup application by adding a new command: 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’ ‘’

Neither of these were successful, but I’m not an experienced user and admit that I may have missed something in attempting the two approaches.

For example, in approach 1, I log in as admin, enter nano ~/.profile in Terminal mode, scroll to the last line of the rather long text and type in the rfkill command and press enter (there are a number of key strokes listed across the bottom, but no save option). Upon Restart, the computer boots up with wlan and bluetooth on. Even if I open the terminal and enter root through the su command, the result is the same. Both of these approaches result in entering commands in the /admin/.profile path though

Was there a “save” step I missed after entering the rfkill command? Should I be booting the computer into root mode instead of allowing it to go through the Ubuntu startup so that I’m truly in the root directory? Or what?

In approach two, I have no problem copying and pasting the gdbus call statement into the command in the GNOME startup applications new command window, and the command shows up when I reenter the GNOME startup applications, but the computer still reboots with the wlan and bluetooth on. Was I suppose to change anything in gdbus call statement? --sessions?, --object-path?

So far, very frustrated!

I would argue that the approach of systemd script will make sure even during booting (10-50 seconds) the device will not reach out to WiFi hot-spots.

I.e. if you care for completely being silent, I guess that’s the only option. Then you can turn on the WiFi and start broadcasting ONLY when you choose to.

IMHO,
Valera Rozuvan

Maybe a partly solution:

turning off bluetooth on startup (works for me on Debian 12; I just did both changes without testing if both are necessary):

  • Edit file /etc/bluetooth/main.conf and set AutoEnable=false.
    • to edit use sudo nano /etc/bluetooth/main.conf
    • If this option is already there as a comment then just remove the # at the beginning. If it’s there with value true just change the value to false. Else insert it.
  • Edit File /etc/default/bluetooth and set BLUETOOTH_ENABLE=0
    • to edit use sudo nano /etc/default/bluetooth
    • Again if this option is already there with value 1 just change the value to 0. Else insert it.

After making these changes my bluetooth is always turned off on startup even if I turned it on before shutting down.