Skip to content
The Chat Archive
sonar-pro-high LMArena Search Arena 24K

ubuntu server linux bluetooth how use though cli

  1. User

    ubuntu server linux bluetooth how use though cli

  2. 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.service
    

    You can check the status of the service with:

    sudo systemctl status bluetooth.service
    

    3. Launch bluetoothctl

    Run the bluetoothctl command 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 on
    

    This 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:BC
    

    You 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 bluetoothctl

    When done, type:

    quit
    

    Additional Notes

    • Non-Interactive Mode: You can also use bluetoothctl commands 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 hcitool or hciconfig, as they are deprecated.

    By following these steps, you can manage Bluetooth devices entirely through the command line on Ubuntu Server[1][3][7].

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.