Akvicor
Akvicor
发布于 2026-07-04 / 0 阅读
0
0

Debian 命令行连接蓝牙

适用于那些最小安装Debian的群体,本身系统没有图形化蓝牙连接界面,因此可以通过命令行的方式配对蓝牙设备

安装

首先需要安装蓝牙设备驱动程序

sudo apt update
sudo apt install -y bluez
sudo systemctl enable --now bluetooth

启动并连接蓝牙设备

# 进入交互式蓝牙控制台
bluetoothctl
# 打开蓝牙硬件
power on
# 启动配对交互处理
agent on
# 让它成为默认处理者
default-agent
# 搜索附近的蓝牙设备
scan on

启动搜索后会不断出现扫描到的蓝牙设备,例如

[NEW] Device AA:BB:CC:DD:EE:FF Sony WH-1000XM5

发现目标设备后就可以连接了

# 建立配对关系,必要时会要求确认配对码
pair AA:BB:CC:DD:EE:FF
# 标记为可信设备,以后允许自动连接
trust AA:BB:CC:DD:EE:FF
# 立即连接耳机
connect AA:BB:CC:DD:EE:FF
# 停止扫描,避免持续占用蓝牙发现过程
scan off
# 退出交互式蓝牙控制台
exit

后续重新连接

已经配对过的设备可以直接进入交互式控制台连接

# 列出所有配对过的设备
bluetoothctl devices Paired
# 查看当前已连接的设备
bluetoothctl devices Connected
# 连接指定设备
bluetoothctl connect AA:BB:CC:DD:EE:FF
# 查看指定设备详细状态
bluetoothctl info AA:BB:CC:DD:EE:FF

找不到设备

先检查蓝牙是否被软阻塞

rfkill list
sudo rfkill unblock bluetooth
sudo systemctl restart bluetooth

蓝牙耳机无法播放

对于最小安装,蓝牙能连接不代表音频已经能播放。若系统没有 PipeWire 蓝牙音频支持,安装

sudo apt install -y pipewire pipewire-pulse wireplumber libspa-0.2-bluetooth
systemctl --user restart pipewire pipewire-pulse wireplumber

bluez 提供 bluetoothctl 和蓝牙守护进程

PipeWire 搭配 BlueZ 用于蓝牙音频输出


评论