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.
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?
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.
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.
To learn about systemd and bash scripting (and out of curiosity) I wrote a script based on ideas in this thread that creates the files (/etc/systemd/system/WifiSoftDisableNM.service and /home/WifiSoftDisableNM.sh) for a systemd.service and activates the service. I didn’t manage to block wifi totally on startup, but on my machine wifi is disabled on displaying gnome login screen.
#!/bin/bash
# Manage service for disabling wifi on boot using NetworkManager
# service already installed? if true offer uninstall and end else proceed
eval "systemctl | grep WifiSoftDisableNM.service 2>&1 >> /dev/null"
if [ $? -eq 0 ] || [ -f /etc/systemd/system/WifiSoftDisableNM.service ] || [ -f /home/WifiSoftDisableNM.sh ]; then
echo "WifiSoftDisableNM.service and/or files already present. Remove? (y/n)"
read userRequest
if [[ "$userRequest" == "y" ]] || [[ "$userRequest" == "Y" ]]; then
echo "disabling WifiSoftDisableNM.service"
sudo systemctl stop WifiSoftDisableNM.service
sudo systemctl disable WifiSoftDisableNM.service
echo "deleting service files"
sudo rm /etc/systemd/system/WifiSoftDisableNM.*
sudo rm /home/WifiSoftDisableNM.sh
echo "reloading daemon"
sudo systemctl daemon-reload
sudo systemctl reset-failed
fi
sudo systemctl status WifiSoftDisableNM.service
exit 0
fi
# verify /usr/bin/nmcli
eval "/usr/bin/nmcli 2>&1 >> /dev/null"
if [ $? -ne 0 ]; then
echo "/usr/bin/nmcli not verified. Aborting."
exit 1
fi
# service not installed - create files and install
echo "Creating files"
echo "Writing timer and/or service file(s)"
cat > ~/WifiSoftDisableNM.sh <<- "EOF"
#!/bin/bash
# Please do not remove this file. It's used by WifiSoftDisableNM.service.
# If you need to remove it you should also remove the service. If you need
# to relocate it then alter the service.
/usr/bin/nmcli radio wifi off
EOF
sudo cp ~/WifiSoftDisableNM.sh /home/WifiSoftDisableNM.sh
rm ~/WifiSoftDisableNM.sh
sudo chmod +x /home/WifiSoftDisableNM.sh
#https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
#https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#
cat > ~/WifiSoftDisableNM.service <<- "EOF"
[Unit]
Description=Soft disable wifi on boot using NetworkManager
After=graphical.target
[Service]
Type=oneshot
ExecStart=/home/WifiSoftDisableNM.sh
[Install]
WantedBy=graphical.target
EOF
sudo cp ~/WifiSoftDisableNM.service /etc/systemd/system/WifiSoftDisableNM.service
rm ~/WifiSoftDisableNM.service
echo "Enabling and starting timer"
sudo systemctl daemon-reload
sudo systemctl enable WifiSoftDisableNM.service
sudo systemctl start WifiSoftDisableNM.service
sudo systemctl status WifiSoftDisableNM.service
exit $?
Just create a file (for example ~/disableWifiOnLogin.sh), copy above code into it, save the file. Make the file executable (for example chmod +x ~/disableWifiOnLogin.sh). Run the file.
To undo the changes of the script simply run it again and answer ‘Remove?’ with ‘y’. If you answer not ‘y’ you will get the output of systemctl status WifiSoftDisableNM.service.
As I mentioned before I’m learning and this comes without any warranty
Ideas, suggestions for improvement, warnings, … are welcome.
Solved! Found my problem with adding: sudo nano ~/.profile; rfkill block wlan and bluetooth was that I didn’t know the ins and outs of the resulting terminal page…didn’t press ^X after entering command, so didn’t Save (Y) change. Once I did, everything worked.
Just a reminder to those who want to help: if a user indicates they are not an experienced linux user, DO NOT assume ANY knowledge. If you suggest a solution, like above, try to include every step (like adding sudo in above and how to save change: ^X, Y.) For an experienced user like yourself this maybe difficult as you are so used to the “obvious” which are not obvious to the inexperienced.
So, to make airplane mode the default on login:
User with administrator rights, go to Terminal page,
Type: sudo nano ~/.profile
Enter: password
Scroll to bottom of page.
Type: rfkill block wlan and bluetooth
Presss: ^ and X simultanously
Type: Y
Restart computer
This means pressing [ Ctrl ] and [ x ] simultaneously.
[Edit]
I missed that one:
I think this one should be sudo rfkill block wlan bluetooth - with sudo without and.
As far as I understand with this method you will also need sudo to turn wifi and bluetooth on again.