How do I install Microsoft OneDrive on Ubuntu 22.04?

Although Microsoft OneDrive is primarily designed for Windows operating systems, it is perfectly possible to use this cloud storage service on Ubuntu thanks to third-party tools. Here’s a step-by-step guide to installing and configuring OneDrive on an Ubuntu system.

Microsoft OneDrive is one of the most popular cloud storage solutions. Although Microsoft does not provide a native application for Linux, the Open Source community has developed tools to fill this gap.

Step 1: Deleting old PPAs and configuration

Before installing the latest version of OneDrive, it’s important to remove any older versions that may have been installed from unofficial sources. If you have tried an installation before.

Delete the old OneDrive client :

sudo apt remove onedrive

Remove the obsolete PPA:

sudo add-apt-repository --remove ppa:yann1ck/onedrive

Ubuntu tends to create a default systemd service for OneDrive. This can cause problems with the new installation.

See also: How do I install OneDrive on an Apple Silicon M1, M2?

We therefore recommend removing this service.

sudo rm /etc/systemd/user/default.target.wants/onedrive.service

Step 2: System update

It is always advisable to update the system before installing new software.

Here’s a little script to do it:

#!/bin/bash
sudo rm -rf /var/lib/dpkg/lock-frontend
sudo rm -rf /var/lib/dpkg/lock
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y

Step 3: Add the OpenSuSE Build Service repository launch key

To guarantee the security and integrity of the packages we install, it’s essential to add the repository’s launch key (or GPG key) before adding the repository itself. The key allows your system to check that downloaded packages have not been altered since their creation.

Run the following command to download the OpenSuSE repository launch key and add it to your system keyring.

wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/obs-onedrive.gpg > /dev/null

Step 4: Add the OpenSuSE Build Service repository

After adding the launch key to guarantee the integrity and security of downloaded packages, the next step is to add the OpenSuSE Build Service repository to your list of package sources. This is the repository from which you’ll install the OneDrive client for Ubuntu.

Use the following command to add the OpenSuSE Build Service repository to your system:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/obs-onedrive.gpg] https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_22.04/ ./" | sudo tee /etc/apt/sources.list.d/onedrive.list

Step 5: Updating system packages

Update the packages again to incorporate the changes:

sudo apt update & sudo apt upgrade

Step 6: Install OneDrive on Ubuntu 22.04

Once you’ve correctly configured the OpenSuSE Build Service repository and updated your system’s package list, you can now move on to installing the OneDrive client. This will enable you to easily synchronize your OneDrive files with your Ubuntu machine.

Enter the following command to install OneDrive from the repository you added:

sudo apt install onedrive -y

Once the installation is complete, you can check that OneDrive is correctly installed by simply typing :

onedrive --version

This should display the version of the OneDrive client you have installed.

How do I install Microsoft OneDrive on Ubuntu?

Step 7: Launch OneDrive on Ubuntu 22.04 ?

Once OneDrive has been installed on your Ubuntu system, it’s time to start it up and configure it to access your files stored in the cloud.

In the terminal, enter the following command:

onedrive

When you run this command for the first time, OneDrive will provide you with a link to connect to your Microsoft account and authorize the application to access your files.

Access the link provided: Copy the link displayed in the terminal and paste it into your favorite web browser.

Authorize access: Log in to your Microsoft account if you haven’t already done so. You will then be prompted to authorize the OneDrive client application to access your files. Click on the “Yes” or “Authorize” button to confirm.

Back to terminal: Once authorization has been granted, you will be redirected to a blank page. Copy the complete URI from your browser’s address bar.

Paste the URI into the terminal: Return to your terminal and paste the URI where indicated (usually after the text “Enter response URI”). Press the “Enter” key.

You should see a message indicating that OneDrive has been successfully authorized and is ready for use.

Step 8: Synchronize your files

To synchronize your OneDrive files with your local system, use the following command:

onedrive --synchronize

This command retrieves all your files stored in OneDrive and synchronizes them with a local folder on your Ubuntu system.

Conclusion

OneDrive is now ready to use on your Ubuntu 22.04. This means you can access, synchronize and manage your files just as you would with any other cloud storage application. So be sure to check for updates regularly to benefit from the latest features and security patches.

For all other Linux versions and distributions, please consult the documentation here.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.