Skip to main content

Command Palette

Search for a command to run...

How to Connect Bluetooth Device in CLI Kali Linux

Updated
6 min read

Connecting a Bluetooth device in Kali Linux using the command line interface (CLI) might seem tricky at first. But once you get the hang of the commands and tools, it becomes straightforward. Whether you want to pair headphones, a keyboard, or any other Bluetooth gadget, you can do it all without a graphical interface.

In this article, I’ll guide you through the process step-by-step. You’ll learn how to scan for devices, pair, trust, and connect them using Kali Linux’s CLI tools. Plus, I’ll share some tips to troubleshoot common issues. By the end, you’ll feel confident managing Bluetooth devices directly from the terminal.

Understanding Bluetooth in Kali Linux CLI

Bluetooth in Kali Linux is managed through several command-line tools. The most common ones are bluetoothctl, hciconfig, and rfkill. These tools help you control the Bluetooth adapter, scan for devices, and manage connections.

  • bluetoothctl: This is the main interactive tool to manage Bluetooth devices. It lets you scan, pair, trust, and connect devices.
  • hciconfig: Similar to ifconfig for network interfaces, it shows the status of Bluetooth adapters.
  • rfkill: This tool manages hardware and software blocks on wireless devices, including Bluetooth.

Before connecting any device, you need to ensure your Bluetooth adapter is enabled and working properly.

Step 1: Check and Enable Bluetooth Adapter

First, you want to verify if your Bluetooth adapter is recognized by Kali Linux.

Open your terminal and run:

hciconfig

If you see an output like hci0: Type: Primary Bus: USB, your adapter is detected. If it’s not listed, your Bluetooth hardware might not be connected or supported.

Next, check if Bluetooth is blocked by software or hardware:

rfkill list bluetooth

If it shows Soft blocked: yes or Hard blocked: yes, you need to unblock it:

sudo rfkill unblock bluetooth

After unblocking, bring the adapter up:

sudo hciconfig hci0 up

This command activates the Bluetooth interface. Now your adapter is ready to scan for devices.

Step 2: Scan for Bluetooth Devices Using bluetoothctl

The bluetoothctl tool is your main interface for managing Bluetooth devices.

Start it by typing:

sudo bluetoothctl

Inside the interactive prompt, turn on the agent and set it to default:

agent on
default-agent

Then, power on the Bluetooth controller:

power on

Now, start scanning for nearby devices:

scan on

You will see a list of devices with their MAC addresses and names appearing as they are discovered. For example:

[NEW] Device 00:1A:7D:DA:71:13 MyBluetoothHeadphones

Once you find your device, note the MAC address. You can stop scanning by typing:

scan off

Step 3: Pair and Trust the Bluetooth Device

Pairing establishes a trusted connection between your Kali Linux system and the Bluetooth device.

In the bluetoothctl prompt, type:

pair <MAC_ADDRESS>

Replace <MAC_ADDRESS> with the actual address of your device. You might be prompted to confirm a PIN or passkey on your device or terminal.

After successful pairing, mark the device as trusted:

trust <MAC_ADDRESS>

Trusting the device allows automatic reconnection in the future without manual approval.

Step 4: Connect to the Bluetooth Device

Once paired and trusted, you can connect to the device:

connect <MAC_ADDRESS>

If the connection is successful, you will see a confirmation message. Your Bluetooth device should now be ready to use.

For audio devices, you may need to configure PulseAudio or ALSA to route sound through the Bluetooth device.

Step 5: Disconnect and Remove Devices

To disconnect a device, use:

disconnect <MAC_ADDRESS>

If you want to remove the device completely:

remove <MAC_ADDRESS>

This deletes the pairing information, so you will need to pair again if you want to reconnect.

Troubleshooting Common Bluetooth Issues in Kali Linux CLI

Sometimes, Bluetooth connections don’t work as expected. Here are some common problems and how to fix them:

  • Bluetooth adapter not found: Make sure your hardware is connected and supported. Check with lsusb or lspci to see if the adapter is recognized.
  • Bluetooth blocked by rfkill: Run sudo rfkill unblock bluetooth to unblock.
  • Device not pairing: Restart the Bluetooth service with sudo systemctl restart bluetooth. Also, ensure the device is in pairing mode.
  • Connection drops frequently: Check for interference or low battery on your Bluetooth device.
  • Audio not routed to Bluetooth headphones: Install and configure pulseaudio and pavucontrol to manage audio devices.

Additional Tips for Managing Bluetooth in Kali Linux CLI

  • Use bluetoothctl commands like devices to list known devices.
  • Use info <MAC_ADDRESS> to get detailed info about a device.
  • To exit bluetoothctl, type exit.
  • Keep your Kali Linux system updated to ensure the latest Bluetooth drivers and tools.
  • For scripting or automation, you can run bluetoothctl commands non-interactively by echoing commands.

Summary Table of Key Commands

CommandPurpose
hciconfigCheck Bluetooth adapter status
rfkill list bluetoothCheck if Bluetooth is blocked
rfkill unblock bluetoothUnblock Bluetooth
sudo bluetoothctlStart Bluetooth control tool
power onTurn on Bluetooth controller
scan onStart scanning for devices
pair <MAC>Pair with a device
trust <MAC>Trust a paired device
connect <MAC>Connect to a device
disconnect <MAC>Disconnect a device
remove <MAC>Remove a paired device

Conclusion

Connecting a Bluetooth device in Kali Linux using the CLI is easier than it looks. By using tools like bluetoothctl, hciconfig, and rfkill, you can manage your Bluetooth adapter and devices without a graphical interface. The key steps are enabling your adapter, scanning for devices, pairing, trusting, and connecting.

If you run into issues, simple troubleshooting steps like unblocking Bluetooth or restarting services usually help. With practice, you’ll find the CLI method fast and reliable for managing Bluetooth devices on Kali Linux. So next time you want to connect a Bluetooth device, just open your terminal and follow these steps.

FAQs

How do I check if my Bluetooth adapter is working in Kali Linux CLI?

Run hciconfig to see if your Bluetooth adapter is listed. If it’s not, check hardware connections or drivers. Also, use rfkill list bluetooth to ensure it’s not blocked.

What is the purpose of bluetoothctl in Kali Linux?

bluetoothctl is an interactive command-line tool to manage Bluetooth devices. It lets you scan, pair, trust, connect, and disconnect devices easily from the terminal.

How can I unblock Bluetooth if it’s disabled?

Use the command sudo rfkill unblock bluetooth to remove software or hardware blocks on your Bluetooth adapter, allowing it to function properly.

Can I connect Bluetooth audio devices using CLI only?

Yes, you can pair and connect audio devices using CLI. However, you may need to configure audio settings with PulseAudio or ALSA to route sound correctly.

What should I do if my Bluetooth device won’t pair?

Make sure the device is in pairing mode and restart the Bluetooth service with sudo systemctl restart bluetooth. Also, try removing old pairings and pairing again.

More from this blog

L

LinuxBloke | Linux Tips, Tricks & Troubleshooting

672 posts