How to sync Microsoft OneDrive with Linux

Microsoft OneDrive is a cloud data storage service similar to IDrive, Google Drive, Dropbox, pCloud, and so on. There is no official Linux client provided by Mircosoft.

As much as we love open source, we can’t deny the fact that proprietary software and services still exist, and are used by a significant group of people. And thanks to the FOSS developers out there who make services and apps for our beloved Linux system, bridging the gap between the FOSS and proprietary software users, to make the life easier.

So in this article, we are going to show how to sync Microsoft OneDrive data to your Linux system. For those not aware of Microsoft OneDrive, it is a cloud data storage service similar to IDrive, Google Drive, Dropbox, pCloud, and so on. Microsoft provides desktop apps for Windows, Android, Mac OS, and iOS platforms. Unfortunately, Linux is left out, but no worries there is OneDrive Free Client for Linux.

OneDrive Free Client Features

It is an open-source client that comes with powerful features such as state caching, Real-Time file monitoring with Inotify, Resumable uploads, support for OneDrive for Business (part of Office 365), and Shared folders. This is a command-line tool and hence it has no GUI.

Sync OneDrive with Linux

We are going to show the installation and configuration of OneDrive Free Client. It is a CLI based program that can be configured to sync the OneDrive data on every boot-up of your system. It is easy to set up and doesn’t need much maintenance or tweaking after installation.

Installation

Dependencies

OneDrive has some dependencies that can be installed in the following ways.

For Ubuntu/Linux Mint and its derivatives:

sudo apt install libcurl4-openssl-dev git
sudo apt install libsqlite3-dev
sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list

This command just added a repository, so you will have to tell your system to trust it. For that, use the following commands:

sudo nano /etc/apt/sources.list.d/d-apt.list

Now after the “deb” part of the first line, insert this:

[trusted=yes]

The file will look like this:

Adding repository permission.
Adding repository permission

Leave spaces on both sides, and save it by pressing CTRL + X, then type ‘y’ and press Enter.

Now continue with this:

sudo apt-get update && sudo apt-get -y install  d-apt-keyring
sudo apt-get update && sudo apt-get install dmd-compiler dub

For Arch Linux and derivatives:

sudo pacman -S curl sqlite dlang git

For Fedora:

sudo yum install libcurl-devel git
sudo yum install sqlite-devel
curl -fsS https://dlang.org/install.sh | bash -s dmd

Downloading and compiling the program

Now that we are done with the dependencies, we can go ahead and install the program.

First, we download the files:

git clone https://github.com/skilion/onedrive.git

Then compile and install it:

cd oneDrive
make
sudo make install

OneDrive installation.
OneDrive installation on Linux Mint

Configuration

After the program launch, it will download all of your files to a directory named OneDrive, which is created in your home directory. This section is only for those who want to change the destination directory or add exceptions to the files that get synced.

Enter the following commands to create a configuration file for OneDrive:

mkdir -p ~/.config/onedrive
cp ~/onedrive/config ~/.config/onedrive/config

And now edit it:

nano .config/onedrive/config

It will look something like this:

OneDrive configuration file.
OneDrive configuration file

if you want to change the destination directory, you can change it here. As shown, it is a directory named OneDrive in your home directory.

Now to skip any specific type of files, you have to add its extension. For example, if I did not want any Python files to be synced, I shall add the .py extension to the line skip_file. It is done as follows:

OD Config file 2
Not allowing Python files to sync

So add a pipe symbol (|), put an asterisk (*), and write the extension of the file you want to reject.

Running the program

Finally comes the stage when you run the program. Even though this looks like the main part of the whole process, it is a one-time requirement.

Run in the Terminal:

onedrive

You will see a link on your Terminal:

Launching OneDrive
Launching OneDrive

Copy the link, and open it in your browser. When you open it, the Microsoft Account login screen will appear. Sign in, and click on ‘Yes’ when the prompt asks if you want to let the application access your data.

Microsoft permission prompt.
Microsoft permission prompt

The sign in will end in a blank window. When the blank window appears, copy the link of that page, and paste it back into the Terminal. Press Enter and the download of your files will begin.

Hence, your OneDrive files are synced with your Linux system.

Automation

If you want to keep your system up-to-date with your drive, you might want to start this program at login itself. To do that, enter these commands:

sudo systemctl --user enable onedrive
sudo systemctl --user start onedrive

OneDrive Client Uninstallation

For some reason, if you think the tool is not for you, here are the uninstallation commands that should be entered in the Terminal.

sudo make uninstall
rm -rf .config/onedrive

Conclusion

All your OneDrive files are synced to the OneDrive directory on your Linux system. OneDrive lets you make even more configurations to your synchronized directory. You can check them here. Let us know what you think about this program in the comments. Cheers!

SourceONEDRIVE
Pulkit Chandak
Pulkit Chandak is a Linux enthusiast and has been using and experimenting with open source software, and hardware too since a long time. He is a huge admirer of open source software and wants to ventilate it to all around him. He is interested in reviewing and writing tutorials on Linux and its innumerable distributions. He believes that freedom in software leads to freedom of the mind from the chains of limits.

8 COMMENTS

  1. Thanks for the guide; however, the command:
    sudo systemctl –user enable onedrive
    results in:
    Failed to connect to bus: No such file or directory
    Thus, no automatic syncing after the first sync.

  2. I have the same problem as Kim Ludvigen, I get the sam directory does not exist reply. However, if I look in my personal folder, There is a directory OneDrive created with some test files included.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,529FansLike
171FollowersFollow

LATEST ARTICLES

How to create Manjaro Linux Live USB drive in Windows PC

Create Manjaro Live USB flash drive
Manjaro Linux is based on the independently developed Arch operating system.  Arch Linux is already known to be an exceptionally fast, powerful, and lightweight distribution. But Arch Linux is typically targeted to geeks who have some Linux background and command-line usage.

RECENT COMMENTS

PDF EDITORS LINUX
In this article, we will take a look at 10 of the best PDF editors and tools out there in 2019 that are available for Linux platforms. The editors are going to be judged on the basis of their functionalities, portability, ease of installation, price, and convenience.
Application Launchers for Ubuntu
Ubuntu is one of the most used Linux distributions worldwide. It is also the reason why it has the maximum number of available programs for itself. Today we are going to talk about one category of those programs, the application launchers.
Uninstall Programs in Ubuntu
Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.
best video players for linux
Most Linux-based systems come with a built-in video player, but let's be honest, it most definitely won't be able to satisfy all of your requirements, due to the fact that default software is mostly made for basic purposes. In this article, we will review the 5 Best Video Players for Linux and thoroughly discuss their features as well as their pros and cons.
best linux distros beginners
Making the shift to Linux is not as complicated as some people make it out to be. There is a variety of Linux distributions available that cater to the needs of people who are planning on making the jump to Linux from any other operating system.