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?
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:
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
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)
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
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)
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:
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.