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.

15 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.

  3. Problem at git ans cd onedrive:
    sceen text:

    W: GPG error: https://netcologne.dl.sourceforge.net/project/d-apt d-apt Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY EBCF975E5BA24D5E
    E: The repository ‘https://netcologne.dl.sourceforge.net/project/d-apt d-apt Release’ is not signed.
    N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    david@david-TP500LN:~$ git clone https://github.com/skilion/onedrive.git
    fatal: destination path ‘onedrive’ already exists and is not an empty directory.

  4. Hi,
    I did get the onedrive to sync, however, these are not on Linux mint 19

    sudo systemctl –user enable onedrive
    sudo systemctl –user start onedrive

    So I have tried Startup applications instead.

  5. Hi,
    during compilation I get the following error message:

    make
    echo v1.1.3 >version
    dmd -g -ofonedrive -O -L-lcurl -L-lsqlite3 -L-ldl -J. src/config.d src/itemdb.d src/log.d src/main.d src/monitor.d src/onedrive.d src/qxor.d src/selective.d src/sqlite.d src/sync.d src/upload.d src/util.d
    src/sqlite.d(142): Deprecation: foreach: loop index implicitly converted from size_t to int
    sed “s|@PREFIX@|/usr/local|g” onedrive.service.in > onedrive.service

  6. This isn’t a real replacement. No GUI, and I hope you don’t have more on your OneDrive than you do on your PC in terms of space, or guess what? This will fill your HDD.

  7. I run into a problem in the Downloading and compiling the program step, specifically the “make” command results in the following

    make: *** No targets specified and no makefile found. Stop.

    • Got that to work through instructions on the github page.

      Still having issues with:
      sudo systemctl –user enable onedrive
      and
      sudo systemctl –user start onedrive

      I get the following Error
      Failed to connect to bus: No such file or directory

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

24,263FansLike
192FollowersFollow

LATEST ARTICLES

Create a ClamAV Antivirus Live USB drive, and how to use it

Antivirus Live CD or USB drives come in handy at times when your computer is infected with a virus and other malware. Here is how you can create a ClamAV Live USB drive to scan and remove the malware from a computer.
terminate frozen app
For dealing with a frozen app or desktop, you can't use the CTRL+ALT+DEL in Linux system. Instead, there are powerful alternatives that come in handy in frustrating situations. We pick the best methods available for you.
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.
Ubuntu 19.10 beta overview
It may be early, but I've been looking forward to the release of Ubuntu 19.10 for some time now. As an impatient person, and promised readers in the FOSSLinux article announcing the release of Eoan Ermine that we would provide you a review of Ubuntu 19.10 Eoan Ermine - Beta.  So, here it goes.