90

Ubuntu 13.04 64 bits, on ELiteBook 8740, gnome desktop with bluetooth-applet shown.

I could not figure out how to turn on and off from shell the Bluetooth and not from the notification bt applet menu. I need to turn on the service and the thing from menu from shell or C.

service bluetooth start/stop has noting to do with the applet button menu item because here are the four scenarios I can see.

  1. Service off, menu item from applet is off (shows turn on)

    bt-device --list yields bluez service is not found

  2. Service on, (sudo service bluetooth start) menu item from applet is off (shows turn on)

    bt-device --list yields rg.bluez.Error.NoSuchAdapter: No such adapter

  3. Service on, menu item from applet is on (shows turn off)

    bt-device --list yields

    Added devices:
    HMDX JAM (36:8F:E8:07:B2:CA)
    Mint Speaker (5BA5) (01:19:53:4C:5B:A5)
    
  4. Service off, menu item from applet is on (shows turn off)

    bt-device --list yields bluez service is not found

I want to be able to turn on and off the Bluetooth as is being done from the applet button. How can I do this?

Pablo Bianchi
  • 17,552
user2195463
  • 1,011

7 Answers7

118

The commands you're looking for are:

rfkill block bluetooth

and

rfkill unblock bluetooth

To toggle on/off:

rfkill toggle bluetooth
Marcus
  • 2,653
33

To stop :

sudo /etc/init.d/bluetooth stop

To start :

sudo /etc/init.d/bluetooth start

To restart :

sudo /etc/init.d/bluetooth restart
Anwar
  • 77,924
Chester
  • 1,098
  • 8
    The use of service is preferred over /etc /init.d/, but this works as well. – Gerhard Burger Nov 23 '13 at 21:15
  • 1
    this is not correct. turning off bluetooth and stopping the service are different things (most notably, the latter requires sudo permissions). – Marcus Oct 07 '16 at 19:57
28

On systems that use systemd, including Ubuntu 15.04 and later:

systemctl start bluetooth

for turning on Bluetooth

systemctl stop bluetooth

for turning off Bluetooth

systemctl restart bluetooth

for restarting Bluetooth

  • 1
    werewolf_65 - FYI you can omit .service because it is assumed if there is no extension (and who likes typing) – Zanna Dec 31 '17 at 10:24
  • 1
    @Zanna alright. Now it is clearer, should have considered to edit the answer like you did... – Thomas Dec 31 '17 at 10:26
  • 1
    I also discovered that I had too reboot, as there was some state info that wasn't reset without that. Now all is working properly - I hope this helps others. Beware of attempting to turn on bluetooth through Settings. And when working with keyboard/mouse that used a 2.4 Ghz dongle, I needed the bluttooth on, even though I would have thought that as being irrelevant. – JoelParke Apr 23 '21 at 20:54
7

Try this, it worked for me: From: bluetooth keeps turning off in 19.04 after physically and manually turning off bluetooth device, any fix to this?

$ sudo rmmod btusb
$ sudo modprobe btusb
nirala
  • 214
  • 2
  • 4
3

If you have tlp installed you can use:

$ bluetooth on  # To start 
$ bluetooth off # To stop

To install TLP:

$ sudo apt install tlp
Grammargeek
  • 2,792
1

I know this is a quite old question.

service

command worked for me.

To stop the service -

service bluetooth stop

To start the service -

service bluetooth start

  • Hi Mitesh. How is your answer better/different from the others? Great you want to contribute though. I recommend you to add this as a comment under existing similar answers, as it is already answered very similarly previously :) – denNorske Sep 11 '21 at 20:15
  • This answer represents an alternative to "sudo /etc/init.d/bluetooth stop" as mentioned in the comments of the above answer. – zx485 Sep 11 '21 at 22:51
0

What worked for me was to install bluez:

  1. Go to http://en.archive.ubuntu.com/ubuntu/pool/universe/b/bluez-tools/

  2. Select your compatible version

  3. Install it manually

Zanna
  • 72,471
noname
  • 1
  • 1
    Installing extra SW to achieve something built-in is never a good idea and leads to hellish problems down the road. If systemctl stop doesn't work then there are other issues. https://askubuntu.com/a/990973/232407 – RichieHH May 14 '21 at 07:09