Bluetoothctl: Difference between revisions

From DikapediaV2
Jump to: navigation, search
(Created page with "<b>Bluetoothctl</b> is a command-line tool used to interact with the Bluetooth subsystem on Linux systems. It provides a text-based interface for managing Bluetooth devices, including discovering, pairing, connecting, and configuring Bluetooth devices. Key Features of <b>Bluetoothctl</b>: * <b>Device Discovery</b>: Scan for nearby Bluetooth devices. * <b>Pairing</b>: Pair with Bluetooth devices. * <b>Connecting</b>: Establish a connection with paired devices. * <b>Trust...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 9: Line 9:
* <b>Power Control</b>: Turn Bluetooth on or off.
* <b>Power Control</b>: Turn Bluetooth on or off.
* <b>Device Information</b>: Retrieve information about connected and discovered devices.
* <b>Device Information</b>: Retrieve information about connected and discovered devices.
Reference: https://usercomp.com/news/1466027/bluetooth-headset-pairing-issue-in-linux


====Check bluetooth service====
====Check bluetooth service====
----
----
  $ sudo systemctl status bluetooth
  $ sudo systemctl status bluetooth


====Enable Bluetooth Adapter====
====Enable Bluetooth Adapter====
----
----
Use <b>rfkill</b> command.  
Use [[Rfkill|<b>rfkill</b>]] command.  


  $ rfkill list all
  $ rfkill list all
  $ sudo rfkill unblock bluetooth
  $ sudo rfkill unblock bluetooth


====Scan Bluetooth Devices====
====Scan Bluetooth Devices====
Line 30: Line 32:
  .
  .
  .
  .


====See Bluetooth Devices====
====See Bluetooth Devices====
Line 39: Line 40:
  Device D6:A3:C1:F9:2C:21 MX Master 3S
  Device D6:A3:C1:F9:2C:21 MX Master 3S
  Device C7:A2:BB:7F:F3:49 MX Anywhere 2S
  Device C7:A2:BB:7F:F3:49 MX Anywhere 2S


====Pair and Connect a Bluetooth Device====
====Pair and Connect a Bluetooth Device====
Line 54: Line 54:
   Attempting to connect to D6:A3:C1:F9:2C:21
   Attempting to connect to D6:A3:C1:F9:2C:21
   Connection successful
   Connection successful


====Trusting a Bluetooth Device====
====Trusting a Bluetooth Device====

Latest revision as of 17:37, 30 July 2025

Bluetoothctl is a command-line tool used to interact with the Bluetooth subsystem on Linux systems. It provides a text-based interface for managing Bluetooth devices, including discovering, pairing, connecting, and configuring Bluetooth devices.

Key Features of Bluetoothctl:

  • Device Discovery: Scan for nearby Bluetooth devices.
  • Pairing: Pair with Bluetooth devices.
  • Connecting: Establish a connection with paired devices.
  • Trusting: Mark devices as trusted to allow automatic connections in the future.
  • Agent Management: Manage Bluetooth agents, which handle pairing requests and PIN/passkey entry.
  • Power Control: Turn Bluetooth on or off.
  • Device Information: Retrieve information about connected and discovered devices.


Reference: https://usercomp.com/news/1466027/bluetooth-headset-pairing-issue-in-linux


Check bluetooth service


$ sudo systemctl status bluetooth

Enable Bluetooth Adapter


Use rfkill command.

$ rfkill list all
$ sudo rfkill unblock bluetooth

Scan Bluetooth Devices


$ sudo bluetoothctl scan on
Discovery started
.
.
.

See Bluetooth Devices


$ bluetoothctl devices

$ bluetoothctl devices | grep -i mx
Device D6:A3:C1:F9:2C:21 MX Master 3S
Device C7:A2:BB:7F:F3:49 MX Anywhere 2S

Pair and Connect a Bluetooth Device


$ dzdo bluetoothctl pair <device MAC>

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Paired: yes
Pairing successful

Once the pairing is complete, you need to connect the Bluetooth device:

$ sudo bluetoothctl connect D6:A3:C1:F9:2C:21
 Attempting to connect to D6:A3:C1:F9:2C:21
 Connection successful

Trusting a Bluetooth Device


If the pairing failed due to error "AuthenticationRejected", you may have to trust it first:

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
Failed to pair: org.bluez.Error.AuthenticationRejected

$ dzdo bluetoothctl trust D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Trusted: yes
Changing D6:A3:C1:F9:2C:21 trust succeeded

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Paired: yes
Pairing successful