💙 Bluetoothコマンドまとめ
Linux環境では、Bluetoothデバイスの管理を行うための複数のコマンドラインツールが用意されています。ここでは、代表的なBluetoothコマンドをわかりやすく整理します。
🔹 主なBluetooth関連ツール
| ツール名 | 用途 |
|---|---|
bluetoothctl |
Bluetoothデバイスの操作・管理(接続、ペアリング、削除など) |
hciconfig |
Bluetoothアダプタの設定・状態確認 |
hcitool |
デバイスのスキャン、接続、情報取得(旧式・非推奨) |
btmgmt |
Bluetooth設定の低レベル制御 |
rfkill |
BluetoothやWi-Fiの無効化/有効化 |
🔹 基本操作(bluetoothctl)
Bluetooth管理モードに入る
bluetoothctl
対話モードでコマンドを入力します。
電源をオンにする
power on
デバイスをスキャンする
scan on
→ 近くのBluetoothデバイスを検出します。
スキャン停止:
scan off
デバイスをペアリング
pair XX:XX:XX:XX:XX:XX
信頼済みデバイスに登録(自動接続)
trust XX:XX:XX:XX:XX:XX
接続する
connect XX:XX:XX:XX:XX:XX
切断する
disconnect XX:XX:XX:XX:XX:XX
ペアリング解除
remove XX:XX:XX:XX:XX:XX
登録済みデバイス一覧を表示
devices
🔹 Bluetoothアダプタの状態確認
hciconfig
有効化/無効化:
sudo hciconfig hci0 up
sudo hciconfig hci0 down
🔹 Bluetooth全体のON/OFF制御(rfkill)
状態確認:
rfkill list
Bluetoothを無効化:
sudo rfkill block bluetooth
Bluetoothを有効化:
sudo rfkill unblock bluetooth
✅ まとめ
| 操作内容 | コマンド例 |
|---|---|
| Bluetooth管理モードに入る | bluetoothctl |
| スキャン | scan on |
| ペアリング | pair <MACアドレス> |
| 接続 | connect <MACアドレス> |
| 切断 | disconnect <MACアドレス> |
| 信頼登録 | trust <MACアドレス> |
| アダプタ確認 | hciconfig |
| Bluetooth有効化 | rfkill unblock bluetooth |
このように bluetoothctl や hciconfig などを使えば、GUIなしでもBluetoothデバイスの接続・設定を柔軟に操作できます。