- How to check bluetooth status via terminal
- More information with hciconfig -a
- 🐧 Как подключиться к устройству Bluetooth из терминала Linux
- Установка BlueZ на Linux
- Как выполнить сопряжение и подключиться к устройству Bluetooth
- Использование bluetoothctl для подключения к устройству Bluetooth
- Включите адаптер Bluetooth при запуске системы
- Turn on/off Bluetooth from shell not from applet
- 7 Answers 7
How to check bluetooth status via terminal
I suppose I needed to word my question better. This answer provides me with what I need. With this I can see if my device is on or off based on whether or not it shows up. Thank you for your reply.
More information with hciconfig -a
hciconfig -a provides way more information, including the Bluetooth version.
$ hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DC:70:13 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:1013 acl:0 sco:0 events:60 errors:0 TX bytes:4890 acl:0 sco:0 commands:60 errors:0 Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'hostname' Class: 0x1c0104 Service Classes: Rendering, Capturing, Object Transfer Device Class: Computer, Desktop workstation HCI Version: 4.0 (0x6) Revision: 0x22bb LMP Version: 4.0 (0x6) Subversion: 0x22bb Manufacturer: Cambridge Silicon Radio (10)
Just press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, You can run this command to see the status of bluetooth
sudo service bluetooth status
after you enter your password, you should see something like
Regardless of whether or not the bluetooth is on i get the same message from that command: bluetooth start/running, process 1132
The Bluetooth icon disappeared.I get the following message. Can anyone please help me what this mean?
ashoke@Dell-3470:~$ sudo service bluetooth status ● bluetooth.service — Bluetooth service Mar 09 15:16:42 Dell-3470 bluetoothd[1141]: Starting SDP server Mar 09 15:16:42 Dell-3470 bluetoothd[1141]: Bluetooth management interface 1.14> Mar 09 16:35:14 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:35:59 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:36:01 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:36:04 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) lines 1-20/20 (END)
This answer was correct for me. I wanted to see if it was active and it said so, I think this answers the question. Thanks for the help:)
An alternative is to use the command hciconfig . It will list clearly the interfaces, and you will see by the marker «RUNNING» or «DOWN» what is their current status.
With BlueZ: Using bluetoothctl (interactive bluetooth control tool), which gives you a terminal with show and these other commands:
[bluetooth]# help Menu main: Available commands: ------------------- advertise Advertise Options Submenu scan Scan Options Submenu gatt Generic Attribute Submenu list List available controllers show [ctrl] Controller information select Select default controller devices List available devices paired-devices List paired devices system-alias Set controller alias reset-alias Reset controller alias power Set controller power pairable Set controller pairable mode discoverable Set controller discoverable mode discoverable-timeout [value] Set discoverable timeout agent Enable/disable agent with given capability default-agent Set agent as the default one advertise Enable/disable advertising with given type set-alias Set device alias scan Scan for devices info [dev] Device information pair [dev] Pair with device trust [dev] Trust device untrust [dev] Untrust device block [dev] Block device unblock [dev] Unblock device remove Remove device connect Connect device disconnect [dev] Disconnect device menu Select submenu version Display version quit Quit program exit Quit program help Display help about this program export Print environment variables
With bluez-tools: bt-* ( apropos bt- ) like bt-device , a bluetooth device manager.
🐧 Как подключиться к устройству Bluetooth из терминала Linux
В этой статье мы обсудим, как вы можете управлять устройством Bluetooth с терминала Linux – дистрибутивов на основе Ubuntu, Debian, Fedora и Arch.
Беспроводная технология Bluetooth является всемирной спецификацией для недорогого решения радиосвязи с малым форм-фактором, которое обеспечивает связь между мобильными компьютерами, мобильными телефонами, другими портативными портативными устройствами и подключение к Интернету.
Спецификация разработана, опубликована и продвигается Специальной группой по интересам Bluetooth (SIG).
В этом руководстве мы будем использовать BlueZ, который обеспечивает поддержку основных уровней и протоколов Bluetooth.
Это гибкий, эффективный инструмент, который использует модульную реализацию. Он имеет следующие ключевые особенности.
- Полная модульная реализация
- С имметричная мульти-безопасная обработка
- Многопоточная обработка данных
- Поддержка нескольких устройств Bluetooth
- Реальная аппаратная абстракция
- Стандартный интерфейс сокетов для всех слоев
- П оддержка безопасности устройств и уровня обслуживания
Установка BlueZ на Linux
Установите пакеты BlueZ с помощью любой из следующих команд, соответствующих вашему дистрибутиву Linux.
----- Ubuntu / Debian ----- $ sudo apt-get -y install bluetooth bluez bluez-tools rfkill ----- Fedora ----- $ sudo dnf -y install bluez bluez-tools ----- Arch Linux / Manjaro ----- $ sudo pacman -S bluez bluez-utils
Эта установка предоставляет утилиту bluetoothctl.
Вам необходимо добавить свою учетную запись в группу lp, если вы хотите подключиться к Bluetooth-модему.
sudo usermod -aG lp $USER newgrp lp
$ systemctl is-enabled bluetooth.service enabled $ systemctl status bluetooth.service ● bluetooth.service - Bluetooth service Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2019-11-30 17:14:12 EAT; 3h 55min ago Docs: man:bluetoothd(8) Main PID: 1638 (bluetoothd) Tasks: 1 (limit: 18590) Memory: 2.3M CPU: 47ms CGroup: /system.slice/bluetooth.service └─1638 /usr/libexec/bluetooth/bluetoothd Nov 30 17:14:12 myfed.example.net systemd[1]: Starting Bluetooth service. Nov 30 17:14:12 myfed.example.net bluetoothd[1638]: Bluetooth daemon 5.52 Nov 30 17:14:12 myfed.example.net systemd[1]: Started Bluetooth service. Nov 30 17:14:12 myfed.example.net bluetoothd[1638]: Starting SDP server Nov 30 17:14:12 myfed.example.net bluetoothd[1638]: Bluetooth management interface 1.14 initialized Nov 30 21:07:52 myfed.example.net bluetoothd[1638]: Endpoint registered: sender=:1.77 path=/MediaEndpoint/A2DPSink/sbc Nov 30 21:07:52 myfed.example.net bluetoothd[1638]: Endpoint registered: sender=:1.77 path=/MediaEndpoint/A2DPSource/sbc
Как выполнить сопряжение и подключиться к устройству Bluetooth
Мы собираемся использовать интерфейс командной строки bluetoothctl tp bluez.
Если у вас есть альтернативный интерфейсный инструмент, такой как GNOME Bluetooth, вы можете использовать его.
Сначала убедитесь, что Bluetooth не отключен.
$ rfkill ID TYPE DEVICE SOFT HARD 0 bluetooth tpacpi_bluetooth_sw blocked unblocked 1 wlan phy0 unblocked unblocked
Подтвердите, что он разблокирован.
$ rfkill ID TYPE DEVICE SOFT HARD 0 bluetooth tpacpi_bluetooth_sw unblocked unblocked 1 wlan phy0 unblocked unblocked 2 bluetooth hci0 unblocked unblocked
Использование bluetoothctl для подключения к устройству Bluetooth
Это общий план сопряжения устройства с использованием bluetoothctl.
Запустите интерактивную команду bluetoothctl.
$ bluetoothctl Agent registered $ bluetoothctl show Controller 20:79:18:5E:4B:64 (public) Name: myfed.example.net Alias: myfed.example.net Class: 0x000c010c Powered: yes Discoverable: no DiscoverableTimeout: 0x00000000 Pairable: no UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb) UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb) UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb) UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb) Modalias: usb:v1D6Bp0246d0534 Discovering: no Advertising Features: ActiveInstances: 0x00 SupportedInstances: 0x05 SupportedIncludes: tx-power SupportedIncludes: appearance SupportedIncludes: local-name
Введите help, чтобы получить список доступных команд.
Включите адаптер Bluetooth
[bluetooth]# agent KeyboardOnly Agent is already registered [bluetooth]# default-agent Default agent request successful [bluetooth]# power on Changing power on succeeded
# scan on Discovery started [CHG] Controller 20:79:18:5E:4B:64 Discovering: yes [NEW] Device 14:AB:C5:CC:C7:AB 14-AB-C5-CC-C7-AB [CHG] Device 14:AB:C5:CC:C7:AB TxPower: 8 [CHG] Device 14:AB:C5:CC:C7:AB Name: DESKTOP-N9GVMQ2 [CHG] Device 14:AB:C5:CC:C7:AB Alias: DESKTOP-N9GVMQ2 [CHG] Device 14:AB:C5:CC:C7:AB UUIDs: 0000110c-0000-1000-8000-00805f9b34fb [CHG] Device 14:AB:C5:CC:C7:AB UUIDs: 0000110a-0000-1000-8000-00805f9b34fb [CHG] Device 14:AB:C5:CC:C7:AB UUIDs: 0000110e-0000-1000-8000-00805f9b34fb [CHG] Device 14:AB:C5:CC:C7:AB UUIDs: 0000111f-0000-1000-8000-00805f9b34fb [CHG] Device 14:AB:C5:CC:C7:AB UUIDs: 0000111e-0000-1000-8000-00805f9b34fb [NEW] Device 5C:FB:7C:A4:13:C6 JBL Clip 3
[bluetooth]# pair 5C:FB:7C:A4:13:C6 Attempting to pair with 5C:FB:7C:A4:13:C6 [CHG] Device 5C:FB:7C:A4:13:C6 Connected: yes [CHG] Device 5C:FB:7C:A4:13:C6 UUIDs: 00001108-0000-1000-8000-00805f9b34fb [CHG] Device 5C:FB:7C:A4:13:C6 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb [CHG] Device 5C:FB:7C:A4:13:C6 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb [CHG] Device 5C:FB:7C:A4:13:C6 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb [CHG] Device 5C:FB:7C:A4:13:C6 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb [CHG] Device 5C:FB:7C:A4:13:C6 ServicesResolved: yes [CHG] Device 5C:FB:7C:A4:13:C6 Paired: yes Pairing successful # trust 5C:FB:7C:A4:13:C6 [CHG] Device 5C:FB:7C:A4:13:C6 Trusted: yes Changing 5C:FB:7C:A4:13:C6 trust succeeded # paired-devices Device 5C:FB:7C:A4:13:C6 JBL Clip 3 # devices Device 5C:FB:7C:A4:13:C6 JBL Clip 3
[bluetooth]# connect 5C:FB:7C:A4:13:C6 Attempting to connect to 5C:FB:7C:A4:13:C6 [CHG] Device 5C:FB:7C:A4:13:C6 Connected: yes Connection successful [JBL Clip 3]# info Device 5C:FB:7C:A4:13:C6 (public) Name: JBL Clip 3 Alias: JBL Clip 3 Class: 0x00200414 Icon: audio-card Paired: yes Trusted: yes Blocked: no Connected: yes LegacyPairing: no UUID: Headset (00001108-0000-1000-8000-00805f9b34fb) UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb) UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb) UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb) ManufacturerData Key: 0x0057 ManufacturerData Value: 01 00 cb 0e d0 1e 03 01 . RSSI: -21 TxPower: 0
Включите адаптер Bluetooth при запуске системы
Чтобы включить адаптер Bluetooth при запуске системы, откройте файл конфигурации.
$ sudo vim /etc/bluetooth/main.conf
Добавьте строку AutoEnable=true
Turn on/off Bluetooth from shell not from applet
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?
7 Answers 7
The commands you’re looking for are:
Thank you, works on Pop_OS! 22.04. My trackpad was someone turned off — happened only when I am not logged in, otherwise the trackpad worked when I was logged out. After executing your commands I managed to get a hold of my blue tooth mouse and go into the settings to enable the trackpad.
sudo /etc/init.d/bluetooth stop
sudo /etc/init.d/bluetooth start
sudo /etc/init.d/bluetooth restart
this is not correct. turning off bluetooth and stopping the service are different things (most notably, the latter requires sudo permissions).
On systems that use systemd , including Ubuntu 15.04 and later:
systemctl start bluetooth
for turning off Bluetooth
systemctl restart bluetooth
werewolf_65 — FYI you can omit .service because it is assumed if there is no extension (and who likes typing)
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.