How to Use Bluetooth on Ubuntu for File Transfer

Even with the emergence and widespread use of modern file transfer protocols and devices, Bluetooth is still a trusted method for file transfers and device connection to and from your system. Your system may or may not come with built-in Bluetooth stack. You can, however, use an external bluetooth dongle to get your goal.

This article explains how to use Bluetooth on your Ubuntu for file transfer, both through the UI and the command line. The article will also help you in resolving any glitches that you may encounter while turning on and transferring files on your Ubuntu. This includes installing the Bluetooth software utility Bluez on your system if it not installed. And also, unblocking Bluetooth if that is the cause of the problem. The GUI is good enough for beginners to work with Bluetooth but the command line is the actual thing you will need to troubleshoot and resolve any Bluetooth connectivity problems.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Use Bluetooth Through the Graphical User Interface

In order to use bluetooth on your Ubuntu, you need to ensure that the Bluez utility is installed on your system. All the latest versions of Ubuntu have Bluez installed by default. However, if your system lacks it, Bluez can be installed both through the Ubuntu Software manager and the command line. This utility is developed by Canonical and is available on the Snap store.

How to Install Bluez (If Your System Lacks It)

For a person who does not want to open the Command Line much, installing software present in the Ubuntu repository through the UI is very simple. On your Ubuntu desktop Activities toolbar/dock, click the Ubuntu Software icon.

Ubuntu Software Center Icon

In the following view, click on the search icon and enter Bluez in the search bar. The search results will list the Bluez entry as follows:

Search for Bluez

Click bluez and the following view will appear:

Install Bluez Bluetooth software

Click the Install button to begin the installation process. The following authentication dialog will display for you to provide your authentication details as only an authorized user can install software on Ubuntu.

Authenticate as admin

Enter your password and click the Authenticate button. After that, the installation process will begin, displaying a progress bar as follows.

Installing Bluez

Bluez for Ubuntu will then be installed on your system and you will get the following message after a successful install:

Launch Bluetooth Software

You should now be able to use your bluetooth. In case you encounter any problem after installation through this method, please refer to the section of this article that explains the use of the software through the command line.

How to Turn the Bluetooth On

The most convenient way to turn on your system’s Bluetooth and configure it is through the Ubuntu Settings utility.

In order to access Settings, click on the downward arrow located at the top-right corner of your Ubuntu screen, and then click the settings icon from the following view:

Turn Bluetooth on

Alternatively, you can enter ‘settings’ in your Ubuntu’s application launcher search to open the Settings directly.

Ubuntu Settings

The Settings utility opens in the Wi-Fi tab by default. You need to click on the Bluetooth tab in order to turn on and configure Bluetooth.

This is how the Bluetooth view looks like:

Bluetooth settings

You can see that the slider button in the top bar is turned off. Simply turn this button on in order to turn on the Bluetooth service/device on your system.

You can also open the Bluetooth settings directly through the application launcher search as follows: Bluetooth

How to Use Bluetooth for File Transfer

As soon as you turn Bluetooth on, it will start scanning for any Bluetooth devices around you. Click on the device you want to connect to/pair with. Your system will now generate a PIN and display it on your Bluetooth device as well.

Confirm Bluetooth PIN

You need to make sure that the PIN displayed on both the devices is the same. Click the Confirm button on the above-displayed dialog in order to confirm that both the PINs match. Now your system’s Bluetooth will be paired with the Bluetooth on your external device and is set up to share files.

Bluetooth Device Paired

You can now share files to and from your Ubuntu system.

Use Bluetooth Through the Command Line-Terminal

How to Install Bluez (If Your System Lacks It)

Bluetoothctl is a command line utility for pairing Bluetooth devices to your system’s Bluetooth. Most Linux systems have the Bluez utility installed by default and it also comes with bluetoothctl. However, if your system lacks it, you can install it by using one of the following commands:

$ sudo apt-get install bluez

Or,

$ sudo snap install bluez

You can open the Ubuntu command line, the Terminal, either through the application launcher search or the Ctrl+Alt+T shortcut.

Please note that only an authorized user can add, remove, and configure software on Ubuntu.

Install bluez on the shell

You can verify if bluetoothctl is installed on your system by running the following command:

$ bluetoothctl --version

How to Turn the Bluetooth On

Through the following command, you can check if your system’s Bluetooth is currently in on or off state:

$ sudo rfkill list

Check Bluetooth state

The Bluetooth device’s Soft blocked status indicates if the device is on or off.

Soft blocked: yes-the device is turned off

Soft blocked: no-the device is turned on

Use the following command in order to unblock/turn on the Bluetooth stack:

$ sudo rfkill unblock bluetooth

Unlock Bluetooth

Your Bluetooth stack is now ready for use and file transfer.

How to Use Bluetooth for File Transfer

Now we will make use of the powerful bluetoothctl utility in order to pair your system’s Bluetooth with an external device for file transfer.

First, enter the following command in order to start using the utility:

$ bluetoothctl

Linux Bluetoothctl command

You Terminal is now in the Bluetooth prompt. Type help in this prompt to see what all you can do here:

Bluetooth command prompt

Let us turn the scan on in order to scan for the available Bluetooth devices around. Enter the following command in the Bluetooth prompt:

# scan on

Scan for Bluetooth devices

The system will start scanning, and then list the available Bluetooth devices. Please copy the device ID from the list, of the device you want to connect to. If you want more information on the device, you can use the following command:

# info [device]

Bluetooth Device info

Now, use the following command in order to pair with a certain device:

# pair [device]

Pair Bluetooth Devices in Ubuntu

Now the program will display a passkey on your Bluetooth device. If the passkey matches the one you get through the pair device command, enter yes.

Device Pairing successful

Your device will now be paired with your system’s Bluetooth. Your prompt will also show the name of your device.

Before using the Bluetooth device to transfer files to and from, you need to add the device as a trusted Bluetooth device. Use the following command in order to add a device as trusted:

# trust [device]

Trust info

Once the required device is paired and trusted, you can easily use it for file transfer between the two Bluetooth devices.

Type exit in order to quit bluetoothctl and return to your normal command prompt.

How to Check the Bluetooth version?

In the Bluetooth prompt, you can check the version of your Bluetooth software through the following command:

# version

Check Bluetooth version

How to turn off Bluetooth?

It is a good security practice to switch off your system’s bluetooth as soon as you are done with the file transfers. Enter the following command in your Terminal after you have exit bluetoothctl with the exit command:

$ sudo rfkill block bluetooth

Lock Bluetooth

This is all you need to know in order to use the Bluetooth facility on your Ubuntu. The command line definitely provides many more options that you can utilize for device pairing. However, the UI interface is also good enough to work with basic file transfer.