hcitool is a command-line tool for interacting with Bluetooth devices on Linux systems. It can be used to monitor, configure connections, and send special commands to Bluetooth devices.
hcitool can be used to perform a variety of tasks, such as:
- Scanning for nearby Bluetooth devices: hcitool scan will scan for nearby Bluetooth devices and display their MAC addresses and device names.
- Connecting and disconnecting from devices: hcitool cc [MAC address] can be used to connect to a device, and hcitool dc can be used to disconnect from a device.
- Configuring connections: hcitool lq [MAC address] can be used to view the link quality of a connected device, and hcitool auth can be used to authenticate a device.
- Sending special commands: hcitool cmd [command] can be used to send special commands to a Bluetooth device. Some examples of special commands include “inquiry” to discover nearby devices, and “reset” to reset the device.
hcitool can also be used in conjunction with other command-line tools, such as sdptool and l2ping to perform more advanced tasks such as querying SDP services or checking the responsiveness of a device. In order to use hcitool, the system must have a Bluetooth adapter and the bluez package installed. It’s important to note that hcitool is a command-line tool and it is recommended to use it with some knowledge of command line and Bluetooth protocol
If you encounter the below error while running the command hcitool:
hcitool: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install bluez |
Ubuntu | apt-get install bluez |
Alpine | apk add bluez |
Arch Linux | pacman -S bluez |
Kali Linux | apt-get install bluez |
CentOS | yum install bluez |
Fedora | dnf install bluez |
Raspbian | apt-get install bluez |
hcitool Command Examples
1. Scan for Bluetooth devices:
# hcitool scan
2. Output the name of a device, returning its MAC address:
# hcitool name bdaddr
3. Fetch information about a remote Bluetooth device:
# hcitool info bdaddr
4. Check the link quality to a Bluetooth device:
# hcitool lq bdaddr
5. Modify the transmit power level:
# hcitool tpl bdaddr 0|1
6. Display the link policy:
# hcitool lp
7. Request authentication with a specific device:
# hcitool auth bdaddr
8. Display local devices:
# hcitool dev