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 many distributions. He believes that freedom in software leads to freedom of the mind from the chains of limits.

30 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

  8. When running this:
    tim@tim-X540SA:~/onedrive$ nano .config/onedrive/config

    I get this message:
    [ Directory ‘.config/onedrive’ does not exist ]
    and an otherwise blank screen

    I’m a newbie and now lost. Please help.
    Thank you in advance.
    Tim

  9. When running this:
    tim@tim-X540SA:~/onedrive$ nano .config/onedrive/config

    I get this message:
    [ Directory ‘.config/onedrive’ does not exist ]
    and an otherwise blank screen

    I’m a newbie and now lost. Please help.
    Thank you in advance.
    Tim

    [code]
    System: Host: tim-X540SA Kernel: 5.0.0-37-generic x86_64 bits: 64 compiler: gcc v: 7.4.0
    Desktop: MATE 1.22.2 wm: marco dm: LightDM Distro: Linux Mint 19.3 Tricia
    base: Ubuntu 18.04 bionic
    Machine: Type: Laptop System: ASUSTeK product: X540SA v: 1.0 serial:
    Mobo: ASUSTeK model: X540SA v: 1.0 serial: UEFI: American Megatrends
    v: X540SA.210 date: 04/13/2016
    Battery: ID-1: BAT0 charge: 28.0 Wh condition: 28.2/33.2 Wh (85%) volts: 11.2/11.2
    model: ASUSTeK X550A26 serial: status: Unknown
    CPU: Topology: Quad Core model: Intel Pentium N3700 bits: 64 type: MCP arch: Airmont rev: 3
    L2 cache: 1024 KiB
    flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 12800
    Speed: 1649 MHz min/max: 480/2400 MHz Core speeds (MHz): 1: 1109 2: 1204 3: 2400
    4: 2400
    Graphics: Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics
    vendor: ASUSTeK driver: i915 v: kernel bus ID: 00:02.0 chip ID: 8086:22b1
    Display: x11 server: X.Org 1.19.6 driver: modesetting unloaded: fbdev,vesa
    compositor: marco resolution: 1366×768~60Hz, 1600×900~60Hz
    OpenGL: renderer: Mesa DRI Intel HD Graphics 405 (Braswell) v: 4.5 Mesa 19.0.8
    compat-v: 3.0 direct render: Yes
    Audio: Device-1: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series High
    Definition Audio
    vendor: ASUSTeK driver: snd_hda_intel v: kernel bus ID: 00:1b.0 chip ID: 8086:2284
    Sound Server: ALSA v: k5.0.0-37-generic
    Network: Device-1: Realtek RTL810xE PCI Express Fast Ethernet vendor: ASUSTeK driver: r8169
    v: kernel port: e000 bus ID: 02:00.0 chip ID: 10ec:8136
    IF: enp2s0 state: down mac:
    Device-2: Qualcomm Atheros AR9485 Wireless Network Adapter vendor: AzureWave AW-NE186H
    driver: ath9k v: kernel port: e000 bus ID: 03:00.0 chip ID: 168c:0032
    IF: wlp3s0 state: up mac:
    Drives: Local Storage: total: 465.76 GiB used: 60.17 GiB (12.9%)
    ID-1: /dev/sda vendor: Toshiba model: MQ01ABF050 size: 465.76 GiB speed: 6.0 Gb/s
    serial:
    Partition: ID-1: / size: 456.96 GiB used: 60.17 GiB (13.2%) fs: ext4 dev: /dev/sda2
    USB: Hub: 1-0:1 info: Full speed (or root) Hub ports: 7 rev: 2.0 chip ID: 1d6b:0002
    Device-1: 1-1:2 info: Logitech Unifying Receiver type: Mouse,HID
    driver: hid-generic,usbhid rev: 2.0 chip ID: 046d:c52f
    Device-2: 1-2:4 info: Logitech Classic Keyboard 200 type: Keyboard
    driver: hid-generic,usbhid rev: 1.1 chip ID: 046d:c315
    Device-3: 1-4:3 info: Realtek type: Video driver: uvcvideo rev: 2.0 chip ID: 0bda:57de
    Hub: 2-0:1 info: Full speed (or root) Hub ports: 6 rev: 3.0 chip ID: 1d6b:0003
    Sensors: System Temperatures: cpu: 6280.0 C mobo: N/A
    Fan Speeds (RPM): cpu: 3400
    Repos: No active apt repos in: /etc/apt/sources.list
    Active apt repos in: /etc/apt/sources.list.d/d-apt.list
    1: deb [trusted=yes] https: //netcologne.dl.sourceforge.net/project/d-apt/ d-apt main #APT repository for D (NetCologne – SourceForge)
    Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
    1: deb http: //packages.linuxmint.com tricia main upstream import backport #id:linuxmint_main
    2: deb http: //archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
    3: deb http: //archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
    4: deb http: //archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse
    5: deb http: //security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
    6: deb http: //archive.canonical.com/ubuntu/ bionic partner
    Info: Processes: 223 Uptime: 3h 49m Memory: 3.76 GiB used: 2.64 GiB (70.3%) Init: systemd
    v: 237 runlevel: 5 Compilers: gcc: 7.4.0 alt: 7 Client: Unknown python3.6 client
    inxi: 3.0.32
    [/code]

  10. Nevermind, I found the config file in the folder and it looked correct per your image, so I was then able to continue the process with no other issues. Thank you for your time.

  11. Any way to sync two different Onedrives? I have a Personal Onedrive account and a Business Onedrive account and I would like to sync both but not co-mingle the directories and files.

  12. The details in this article are incorrect as it points to an defunct code repository. The ‘skilion’ OneDrive client ( https://github.com/skilion/onedrive ) appears to have been abandoned and contains many defects that put you at risk of data loss and corruption if you use it. The original author is totally uncontactable despite numerous efforts by myself and others.

    If you wish to use the latest code which contains numerous fixes and enhancements you need to clone & build from this repo: https://github.com/abraunegg/onedrive

    If you wish to use the latest code which contains numerous fixes and enhancements you need to clone & build from that repo as well.

    Major differences / Enhancements:
    =================================
    – Existing bugs with skilion client fixed
    – File upload / download validation to ensure data integrity
    – SharePoint / Office 365 Shared Libraries added
    – Desktop notifications via libnotify
    – Dry-run capability to test configuration changes
    – Prevent major OneDrive accidental data deletion after configuration change

    Further details can be found here: https://abraunegg.github.io/

  13. Works well for me, but the initial make command froze my system! working OK now, and removed the account elevation to enable and start onedrive. Question, do you have to restart to force synch with Onedrive?

    • Yes, your system will be synced with OneDrive on every reboot. Otherwise manually restarting the service should also do the trick. sudo systemctl –user restart onedrive

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,555FansLike
365FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

The 10 Best Linux Server Distros For Home And Businesses

By the year 2020, it is estimated that there are close to 600 Linux distributions in the market. It includes both servers and Desktop versions; therefore, if you are looking for lightweight Linux distribution for your old PC or a reliable desktop version for employees in your organization, you may be overwhelmed with the number of choices for finding one for your use.

How to list the installed Packages on Ubuntu

It is only natural to start installing more and more software on your Ubuntu PC once you start using it. Similarly, it is also natural to lose track of the different packages that you have installed on your system. Eventually, you may be overwhelmed with the number of packages in your system and with the ones you hardly used.

How to configure the Ubuntu Firewall (UFW)

A properly configured firewall is a crucial part of establishing preliminary system security. Keeping this in mind, here we will go over how to configure the firewall on your Ubuntu PC.

How to install and use Zoom on Ubuntu

If you work from home or hold meetings with other people remotely, then you have probably heard of Zoom. It is one of the popular video conferencing software app available today.

How to Restart Networking on Ubuntu

Sometimes resetting your Ubuntu network is required to apply some network configurations like changing your IP from Automatic DHCP to static one. Restarting the network is not a big deal, but should be done carefully.

How to install Chrome and Chromium Browser on Pop!_OS

By default, Pop!_OS comes with Mozilla Firefox Browser installed to help you browse the internet. It is a reliable web browser covering almost all the features and functionalities you need. However, working with Firefox is noticeably different compared to Google Chrome, especially from the speed point of view. Google Chrome is a tad quicker than Firefox.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Pop!_OS 20.04 Review: Professional Linux Distribution Ever Made

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

7 Best Ways to Kill Unresponsive Programs in Linux

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.

[Guide] apt vs apt-get commands, and which one to use?

Most Linux users, both veterans, and newbies, often get confused about what the difference between the Linux commands apt, and apt-get are and when they should use one or the other.

6 ways to find out your Linux file system type

Any Operating system in the market whether its Windows, Linux, Unix, macOS, and any other, must be able to access and manage files and data on storage devices.