Connect to a Bluetooth device from command line in Ubuntu Linux

Bluetooth Headphones
Image: Bluetooth Headphones (License: CC-BY-SA-NC-ND)
Published: Tag Bluetooth

Guide to pair a Bluetooth device from command line.

In this case I will pair a Bluetooth headphone but the process should be similar to any other device.

1. Identify your computer bluetooth

Identify the Bluetooth device we want to scan from with hcitool dev.


$ hcitool dev
Devices:
	hci0	A3:3E:XX:XX:G3:86

2. Scan available devices

Turn on your device (e.g. headphone) so we can find it from the computer with hcitool scan if we have just one or choose the right one like hcitool -i hci0 scan.


$ hcitool -i hci0 scan
Scanning ...
	FC:XX:XX:XX:XX:FE	n/a

3. Trust the discovered device

For future connections, trust the device using bluetoothctl and trust the discovered MAC address.


$ bluetoothctl
[bluetooth]# trust FC:XX:XX:XX:XX:FE
[CHG] Device FC:XX:XX:XX:XX:FE Trusted: yes

4. Connect

You can connect it from the bluetoothctl console or directly with bluetoothctl connect < MAC-address >.


[bluetooth]# connect FC:XX:XX:XX:XX:FE
Attempting to connect to FC:XX:XX:XX:XX:FE
Connection successful
[E7]# 

Extras

Useful commands to deal with Bluetooth devices from bluetoothctl:

  • help
  • devices list available devices
  • paired-devices list paired devices

[E7]# paired-devices
Device FC:XX:XX:XX:XX:FE E7

Resoureces

  • bluetoothctl: - interactive bluetooth control tool (General Commands Manual)
  • hcitool - configure Bluetooth connections (Linux System Administration)
Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus


How to connect to a pair Bluetooth headphones with computer from command line.

Clutter-free software concepts.
Translations English Español

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·