ubuntu server linux bluetooth how use though cli
- User
ubuntu server linux bluetooth how use though cli
- Assistant
To use Bluetooth on an Ubuntu Server through the command line, you can follow these steps. The primary tool for managing Bluetooth devices in Linux is
bluetoothctl, which is part of the BlueZ package. Here's a detailed guide:
1. Install Required Packages
Ensure that the necessary Bluetooth tools are installed:
sudo apt update sudo apt install bluez
2. Start and Enable the Bluetooth Service
Make sure the Bluetooth service is running and enabled to start at boot:
sudo systemctl start bluetooth.service sudo systemctl enable bluetooth.serviceYou can check the status of the service with:
sudo systemctl status bluetooth.service
3. Launch
bluetoothctlRun the
bluetoothctlcommand to enter its interactive shell:bluetoothctl
4. Configure the Bluetooth Controller
- Power On the Controller:
power on - Make the Controller Discoverable and Pairable:
discoverable on pairable on - Set the Default Agent:
agent on default-agent
5. Scan for Devices
To discover nearby Bluetooth devices:
scan onThis will list devices along with their MAC addresses. Note the MAC address of the device you want to connect to.
6. Pair with a Device
Use the MAC address of the target device to pair:
pair <mac_address>For example:
pair 3C:4D:BE:84:1F:BCYou may be prompted to confirm or enter a PIN, depending on the device.
7. Trust the Device
To allow automatic reconnections in the future:
trust <mac_address>
8. Connect to the Device
Once paired, connect to the device:
connect <mac_address>
9. Disconnect or Remove a Device
- To disconnect:
disconnect <mac_address> - To remove a paired device:
remove <mac_address>
10. Exit
bluetoothctlWhen done, type:
quit
Additional Notes
- Non-Interactive Mode: You can also use
bluetoothctlcommands directly without entering the interactive shell. For example:bluetoothctl power on bluetoothctl pair 3C:4D:BE:84:1F:BC bluetoothctl connect 3C:4D:BE:84:1F:BC - Deprecated Tools: Avoid using older tools like
hcitoolorhciconfig, as they are deprecated.
By following these steps, you can manage Bluetooth devices entirely through the command line on Ubuntu Server[1][3][7].
- Power On the Controller:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.