How do I test connecting to a BLE peripheral in Linux?

To activate BT, list controller information and scan for BT/BLE devices:

# bluetoothctl
Agent registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# list
Controller C0:EE:40:50:00:00 summit [default]
[bluetooth]# scan on

To connect to a device acting as a peripheral:

[bluetooth]# scan on
Discovery started
[CHG] Controller C0:EE:40:50:00:00 Discovering: yes
[NEW] Device 4C:90:DE:92:00:00 Pixel XL
[CHG] Device 4C:90:DE:92:00:00 RSSI: -68
[CHG] Device 4C:90:DE:92:00:00 RSSI: -58
[NEW] Device 4C:90:DE:92:00:00 Pixel XL
[bluetooth]# scan off
Discovery stopped
[CHG] Controller C0:EE:40:50:00:00 Discovering: no
[CHG] Device 4C:90:DE:92:00:00 TxPower is nil
[CHG] Device 4C:90:DE:92:00:00 RSSI is nil
[bluetooth]# pair 4C:90:DE:92:00:00
Attempting to pair with 4C:90:DE:92:00:00
[CHG] Device 4C:90:DE:92:00:00 Connected: yes
[NEW] Primary Service
        Generic Attribute Profile
[NEW] Characteristic
[NEW] Characteristic
        First Name
[NEW] Characteristic
        Last Name
[NEW] Characteristic
[CHG] Device 4C:90:DE:92:00:00 UUIDs: 0000181c-0000-1000-8000-00805f9b34fb
[CHG] Device 4C:90:DE:92:00:00 UUIDs: 0000aaa0-0000-1000-8000-aabbccddeeff
[CHG] Device 4C:90:DE:92:00:00 ServicesResolved: yes
Request confirmation
[agent] Confirm passkey 210165 (yes/no): yes
[Pixel XL]# trust 4C:90:DE:92:00:00
[CHG] Device 4C:90:DE:92:00:00 Trusted: yes
Changing 4C:90:DE:92:00:00 trust succeeded

The peripheral device is a Google Pixel XL running Android 10 using Nordic’s nRF app with an advertising profile setup with dummy information. If you pair with a device that does not have some kind of service running, it will disconnect, as BT/BLE has nothing to do.