Get Bluetooth MAC Address via adb [duplicate] Get Bluetooth MAC Address via adb [duplicate] android android

Get Bluetooth MAC Address via adb [duplicate]


Running netcfg will show you all interfaces on the system along with their MAC addresses.


adb shell cat /sys/class/net/wlan0/address


What I usually do to get the mac address of the WiFi interface of an Android device (that is connected to my PC through a USB port) is following these easy steps:

1. Find the device name using:

adb devices

Results usually looks like:

List of devices attached 4e7354af  device1f97033e  device

In this case we have two devices connected 4e7354af and 1f97033e. Let's work on the first one: 4e7354af

2. Get the mac address for the first device:

adb -s 4e7354af shell "ip addr show wlan0  | grep 'link/ether '| cut -d' ' -f6"

The result will be looks like:

8e:5a:e7:c2:01:9b

In previous line, we used the -s option of the adb command to specify the serial number. Then we call the shell command to indicate that we will run a Linux command. Finally, we run the command: ip addr show wlan0 | grep 'link/ether '| cut -d' ' -f6 this command can also be used in Linux if its interface has the same name as wlan0.

I generally use this approach because I have many devices connected to my testing environment. Good luck guys.

Note: If you run commands like cat /sys/class/net/wlan0/address you will get an error like cat: /sys/class/net/wlan0/address: Permission denied due to the security policies of Android.