1. Overview

Bluetooth MAC addresses are unique identifiers assigned to Bluetooth devices, allowing them to communicate within a network. In a Linux environment, extracting the MAC addresses can be useful for various purposes, including troubleshooting connectivity issues or managing device connections.

In this tutorial, we’ll explore the methods to extract Bluetooth MAC addresses on a Linux system.

2. Extracting Bluetooth MAC Address in Linux

Before diving into the methods to extract a Bluetooth MAC address, we need to check whether the Bluetooth service in Linux is active or not. Let’s check the status of the Bluetooth service first with systemctl:

$ systemctl status bluetooth
○ bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; disabled; preset: disabled)
Active: inactive (dead)
Docs: man:bluetoothd(8)

Since the Bluetooth service status is inactive, let’s start the service:

$ sudo systemctl start bluetooth

Once the Bluetooth service is active, we can proceed with the identification of the Bluetooth MAC address.

2.1. Using hcitool

The hcitool is a command-line utility used for Bluetooth device configuration and interaction in Linux. It allows users to perform various tasks, such as scanning for devices, querying information, and establishing connections.

Let’s use hcitool with the dev option to display the MAC addresses of the available Bluetooth devices or adapters that are currently present and recognized by the system:

$ hcitool dev             
        hci0    23:E3:2D:F4:B1:BE

The command output displays the MAC address of the first Bluetooth adapter of the system. Here, the hci stands for Host Controller Interface, and the 0 signifies the first Bluetooth adapter on the system.

2.2. Using bluetoothctl

Another command-line tool to extract the MAC address in Linux is bluetoothctl. The bluetoothctl command provides a convenient way to manage Bluetooth devices, pair and connect to them, and configure various Bluetooth settings.

Let’s utilize bluetoothctl to find the MAC address in Linux:

$ bluetoothctl list
Controller 23:E3:2D:F4:B1:BE user [default]

The output shows the default Bluetooth controller’s MAC address, and hostname (in this case, user).

2.3. Using the Bluetooth Configuration Directory

The Bluetooth configuration directory stores Bluetooth information. We can manually check this directory to find the MAC addresses of the computer’s Bluetooth adapter and Bluetooth devices.

To find the MAC address of the Bluetooth adapter with this method, we’ll need to navigate to the /var/lib/bluetooth configuration directory using the terminal:

$ sudo ls -l /var/lib/bluetooth/ 
total 4
drwx------ 5 root root 4096 Nov 23 14:45 23:E3:2D:F4:B1:BE

The command result shows the Bluetooth configuration directory, which is named after the MAC address of the computer adapter. Further, within the 23:E3:2D:F4:B1:BE directory, we can find subdirectories named after the MAC addresses of Bluetooth devices that have been connected.

3. Conclusion

In this article, we explored different methods to extract Bluetooth MAC addresses in Linux.

Using tools like hcitool and bluetoothctl or exploring the Bluetooth configuration directory, we can identify and work with MAC addresses for various purposes. Extracting Bluetooth MAC addresses on a Linux system can be essential for troubleshooting and managing device connections.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.