How to have bluetooth disabled per default?

6,333

Solution 1

gedit /etc/bluetooth/main.conf

and set this:

AutoEnable = false

A more radical way is to either stop the bluetooth service

sudo systemctl stop bluetooth.service

Or even more radical is to disable it permantly

sudo systemctl disable bluetooth

Solution 2

Here is how you can create a script that will run on startup and perform an action to kill the Bluetooth service, and that would be the following (I use nano, feel free to use any other text editor):

Step 1: Navigate to the folder:

cd /etc/systemd/system/

Step 2: First create a script that will kill the Bluetooth service once run:

nano bluetoothkill.sh

Step 3: Enter the following code, save and exit:

#!/bin/bash
rfkill block bluetooth
exit 0

Step 4: Create a foo.service file in the same folder /etc/systemd/system/ :

nano foo.service

Step 5: Enter the following code, save and exit:

[Unit]
Details=Additional startup scripts
After=network.target

[Service]
ExecStart=/etc/systemd/system/bluetoothkill.sh

[Install]
WantedBy=default.target

Step 6: Run the following command in the terminal:

sudo chmod 744 bluetoothkill.sh

Step 7: Run the following command in the terminal:

sudo systemctl start foo.service

Step 8: Restart the machine and on the next boot you will notice that the Bluetooth service is no longer enabled by default on startup. You can still enable it when ever you like in the settings, or the terminal it is behaving without any errors.

If you like to add more scripts on startup, you can always edit the foo.service file and add additional lines under the [Service] bracket to run additional scripts on startup, for example:

ExecStart=/full-script-filepath/newscript.sh

Share:
6,333

Related videos on Youtube

J.Doe
Author by

J.Doe

Updated on September 18, 2022

Comments

  • J.Doe
    J.Doe over 1 year

    I am using Ubuntu 18.04 on Dell XPS-13 and every time the laptop starts bluetooth is enabled and you have to disable it manual. But i am using it not very often.

    Therefore: is it possible to have bluetooth disabled by default? (i know about the tweak in the rc.local file but since Ubuntu 14.04 the rc.local does not exist and is not used anymore)

    • Broadsworde
      Broadsworde about 6 years
      Have you tried turning off Bluetooth in Settings? I've done that and the setting is retained after shutdown and reboot
    • Elder Geek
      Elder Geek about 6 years
      Please clarify. Your title makes it sound like you want to disable bluetooth by default, but then you ask "is it possible to have bluetooth enabled by default? " Several of us can't understand what your problem is due to this Please edit your post to provide further clarity. Thank you for helpin us help you!
    • Pilot6
      Pilot6 about 6 years
      This is a well known bug.
    • J.Doe
      J.Doe about 6 years
      Im sorry for the confusion between enabled and disabled, i corrected that. @Broadsworde if i turn bluetooth off in the settings it is enabled after a restart.
    • J.Doe
      J.Doe about 6 years
      @Pilot6 but is there a workaround?
    • Rinzwind
      Rinzwind about 6 years
      @J.Doe the settings from the gui does not abide to systemd probably. See if my answer works.
    • Fabby
      Fabby about 6 years
    • J.Doe
      J.Doe about 6 years
      @Fabby the other question does not solve the problem. Like i said in my question: the suggested solution there is to use the rc.local file and since ubuntu 14.04 the rc.local is not existent anymore.
  • Fabby
    Fabby about 6 years
    +1 because this ended up in the LQ queue for some or other reason...
  • J.Doe
    J.Doe about 6 years
    I tried the first solution and disabled bluetooth in the settings if i than reboot my laptop bluetooth is again enabled. But i do not want to disable bluetooth permanently just do not have it enabled by default on start.
  • Fabby
    Fabby about 6 years
    Look at the duplicate mentioned in the comments @J.Doe
  • Rinzwind
    Rinzwind about 6 years
    @J.Doe the edit is still there in /etc/bluetooth/main.conf? Can you show the status of bluetooth.service in the question? And maybe main.conf too? On my 18.04 BT is disabled and stays disabled and I used the settings to do this.
  • J.Doe
    J.Doe about 6 years
    @Rinzwind yes the edit was/is still in the main.conf But "sudo systemctl disable bluetooth" worked and i can still activate bluetooth with the settings if i want to. Thank you
  • Rinzwind
    Rinzwind about 6 years
    @J.Doe cool :-)
  • Sandu Ursu
    Sandu Ursu almost 4 years
    This doesn't work for me..
  • Rinzwind
    Rinzwind almost 4 years
    @SanduUrsu then you are doing something wrong. These 2 have been working for years and still work. I use it every new Ubuntu install and have used it for 20.04 as well.
  • Sandu Ursu
    Sandu Ursu almost 4 years
    It appears that if you use tlp, and don't disable it there, this solution won't work.