Part of the modern computing experience is synchronizing files to cloud storage, such as OneDrive. This way, your files are not at risk of vanishing if your local disk goes kaput. Also, switching computers would no longer involve dragging along an external drive to transfer files.
If your daily driver is a Linux computer, the lack of an official OneDrive client from Microsoft can be off-putting. But don’t worry; there’s a solution, and that’s what this post will teach you.
A computer with Ubuntu 20.04 Desktop or newer. This post will be using an Ubuntu 22.04 Desktop.
Step 1: Update the System
First, let’s ensure that the system is up to date. Open a terminal and run the below command to create a script called update-os.sh on the current directory.
sudo tee -a update-os.sh << EOM #!/bin/bash rm -rf /var/lib/dpkg/lock-frontend rm -rf /var/lib/dpkg/lock apt-get update apt-get upgrade -y apt-get dist-upgrade -y apt-get autoremove -y apt-get autoclean -y EOM
Next, make the script executable and run it:
sudo chmod +x update-os.sh sudo ./update-os.sh
Since we can assume that there are many changes to the system, let’s reboot it before going any further:
Step 2: Install OneDrive for Ubuntu
The OneDrive for Linux client has specific installation sources matching the Ubuntu version.
If installing on a distribution other than Ubuntu, refer to the official OneDrive Client for Linux repository.
First, let’s get the current Ubuntu version of your computer and store it in the os_version variable so that the subsequent commands can use it.
os_version=$(cat /etc/os-release | grep VERSION_ID | tr -d \VERSION_ID=\")
As you can see, this computer is running Ubuntu 22.04.
Next, run this command to add the OpenSuSE Build Service repository release key to your computer’s keyring.
wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_$os_version/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/obs-onedrive.gpg > /dev/null
Now, run this command to add the OneDrive repository to your package source list.
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_$os_version/ ./" | sudo tee /etc/apt/sources.list.d/onedrive.list
Since you’ve added the OneDrive repository, let’s update the package cache.
sudo apt-get update
According to this output, the OneDrive repository is now added and working.
Finally, install the OneDrive for Ubuntu client:
sudo apt install -y --no-install-recommends --no-install-suggests onedrive
After installing the Ubuntu OneDrive client, run the below command to check and confirm its version.
As of this writing, the latest Ubuntu OneDrive client is v2.4.23, as shown below.
Step 3: Install the Ubuntu OneDrive Client GUI
So you’ve installed the Ubuntu OneDrive Client. But how do you use it? Well, the OneDrive Client you just installed is command-line based. Meaning you have to run commands to use it. Did this revelation crush your hopes and dreams for this Ubuntu OneDrive Client? What a bummer.
Note. Learn how to enable Ubuntu screen sharing using Vino VNC.
But don’t worry, there’s an excellent GUI frontend to use OneDrive for Ubuntu more akin to how it works on a Windows client. It’s called, OneDriveGUI.
First, let’s download the latest release from the GitHub repository. You can go to the OneDriveGUI releases page, download the latest AppImage file, or run this command instead.
curl -s https://api.github.com/repos/bpozdena/OneDriveGUI/releases/latest \ | grep "browser_download_url.*x86_64.AppImage" \ | head -1 \ | cut -d : -f 2,3 \ | tr -d \" \ | wget -qi -
After running the command, the AppImage file should be downloaded to the current directory.
Let’s move this file to a location where you’re less likely to accidentally delete it. And while we’re at it, let’s rename the file to OneDrive.AppImage.
sudo mv OneDrive*.AppImage /opt/OneDrive.AppImage ls -l /opt/OneDrive.AppImage
Lastly, we have to make OneDrive.AppImage file executable.
chmod +x /opt/OneDrive.AppImage ls -l /opt/OneDrive.AppImage
On Ubuntu 22.04 and above, make sure to install FUSE2. If you skip this step, OneDriveGUI will not launch.
sudo apt install -y libfuse2
Step 4: Create the OneDrive Shortcut (Dash and Desktop)
At this point, you can start using the Ubuntu OneDrive Client GUI from where you saved it.
But let’s take it up a notch and create a shortcut on the dash and the desktop.
Note. Check our tutorial on how to install Remmina Remote Desktop Client on Ubuntu.
Run the command below in the terminal to save the OneDrive logo to OneDrive.png.
Next, let’s move the logo to /opt, where the OneDrive app is located.
sudo mv OneDrive.png /opt/OneDrive.png
Now, both the OneDriveGUI app and logo are in the same location.
Next, in the text editor, let’s create a file called /usr/share/applications/OneDrive.desktop.
sudo nano /usr/share/applications/OneDrive.desktop
Once the file is in the editor, copy the below code and paste it.
[Desktop Entry] Name=OneDrive Exec=/opt/OneDrive.AppImage Icon=/opt/OneDrive.png comment=OneDrive Client Type=Application Terminal=false Encoding=UTF-8 Categories=Utility;
The file should look like this. Press CTRL+S and CTRL+X to save the file and close the editor.
And you now have a OneDrive shortcut in the dash.
If you want the same shortcut on the desktop, run the below commands in the terminal.
cp -r /usr/share/applications/OneDrive.desktop ~/Desktop/ chmod 775 ~/Desktop/OneDrive.desktop chmod +x ~/Desktop/OneDrive.desktop sudo chown $USER:$USER ~/Desktop/OneDrive.desktop sudo chmod 775 ~/Desktop/OneDrive.desktop sudo chmod +x ~/Desktop/OneDrive.desktop
As you can see, the OneDrive client shortcut was created on the desktop but is blocked from launching.
Right-click on the OneDrive icon and click Allow Launching.
And the OneDrive shortcut becomes enabled.
Step 5: Launch and Configure the Ubuntu OneDrive Client
If you’ve followed the previous steps correctly, you should be able to launch the OneDriveGUI app now.
Double-click the OneDrive icon on the desktop or the dash, and the setup wizard appears. Click Next.
The next page checks if the installed OneDrive Client for Linux is a supported version. If the version check passed, click Next.
On the next page, select Create new OneDrive profile and click Next.
Enter the profile name, preferably your OneDrive username. The sync directory automatically populates. You can change or leave it as is. Now, click Create new profile.
Once the profile is created, click Next.
Click Finish to exit the setup wizard.
Step 6: Authenticate with OneDrive and Start Synching
Remember that in the previous step, you only created a profile for your OneDrive account on the local computer. The synch is not yet running because you haven’t logged in to your account.
Click the start icon on the OneDriveGUI window.
A pop-up window appears, giving your instructions on how to log in. Click the link on the first step to open a browser that leads to the login page.
Login to your account as instructed.
After logging in, copy the response URL from the browser address bar.
Paste the URL you copied into the step 3 box and click Login.
You should get a confirmation box like the one below. Click OK to close it.
Go back to the OneDriveGUI window, and click the play button to start synchronizing.
Your files are now synching between your device and the OneDrive cloud.
Even without the official app for Linux, the free Ubuntu OneDrive client does the job well. It is at par with the OneDrive Client on Windows, although you can add more accounts in OneDrive for Linux.
You can customize the sync options to enable auto sync when the GUI starts or exclude files and folders you do not want to synchronize. You can also limit the bandwidth and adjust the monitoring interval on the networking side.
Give the Ubuntu OneDrive client a try. Take it for a spin. You might find that it’s the answer to your OneDrive sync dilemma on Ubuntu.