How to Sync Microsoft OneDrive with Linux

Sync Onedrive Linux Featured

Sometimes lately it can be necessary to use propriety products. Open source enthusiasts would love to have a cloud-based storage facility, but the fact remains that companies like Google, Amazon, Dropbox and Microsoft have cornered the cloud storage market. They offer reliable products for free, and this means that yes, they will scan or read your files in order to comply with legal requests or to serve adverts. It is a fact of life, but this doesn’t mean you shouldn’t use them.

OneDrive is Microsoft’s cloud-based storage offering, and even though it is naturally suited to the Windows platform, it will connect with Linux-based machines with little effort. There are a number of ways to do this, and this is where the onedrive script comes into play.


Onedrive is a CLI-based client that allows you to sync quickly and easily with OneDrive.

In order to install onedrive, first you need to install some dependencies and set up git, unless you already have it. Head to the Terminal and enter one of the following.

For Ubuntu:

If you are using Ubuntu 18.04 or newer, use snap to install dmd:

If not:

For Fedora:

Arch Linux:


After installing the dependencies, fetch the files with git:

And compile and install it:

After you have done this, now you need to authorize onedrive with Microsoft so it can access your account. Simply enter the following in the Terminal:

And it will prompt you to visit the URL to get authorization.


Log in to your OneDrive account, and grant the app permission to access your account.


Once this is done, you will be presented with a blank white page. Copy the URL and paste it into the Terminal at the prompt.


This will complete the setting up.

To start synchronizing OneDrive to your local folder, run

Onedrive will start downloading all your files in the cloud to your local folder.

Alternatively, you can run:

to get it to monitor your local folder for changes.


You can find the “config” file at the onedrive git folder. To make it active, move it to the “~/.config/onedrive/” folder.

Open the config file. There are three options that you can configure: “sync_dir” and “skip_files.”

  • sync_dir: the location to store your OneDrive files. All files placed in/removed from this folder will be synced to the cloud.
  • skip_files: the file type (or file pattern) that won’t be synced.
  • monitor_interval: the time interval between sync operations.

Once you have made the changes, save and restart onedrive.

At any time, you can check your configuration with the command:


Sync List

If you prefer to use selective sync rather than sync the whole OneDrive folder, you can create a file named “sync_list,” and place it in the “~/.config/onedrive” folder. Inside the file add the relative path (from the synced OneDrive folder) to the files/folders you want to sync.

Starting onedrive at login

By default, onedrive doesn’t start when the user logs in. To get it to run automatically when you log in, you can add onedrive --monitor to your startup application.

Now your OneDrive will sync with your Linux system. How do you sync OneDrive to your setup, and do you prefer other tools? Let us know in the comments section below.

This post was updated in March 2019 with a working repository.

Image credit: Microsoft OneDrive

Damien Damien

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.


  1. Hey! I’m getting an error upon compiling:
    user:~/onedrive $ make
    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
    make: dmd: Command not found
    Makefile:29: recipe for target ‘onedrive’ failed
    make: *** [onedrive] Error 127

    1. You are missing the dlang complier (dmd) in your system. You can download and install it from here (

    2. I had the exact same issue on my first time running “make” after cloning the repo.
      I’m glad you asked this question it was the only real hangup that I had to deal with.

      And thanks to Damien for his quick follow-up response!!

  2. I am having an issue with the starting onedrive at login. The part right here:

    sudo systemctl –user enable onedrive

    Returns this at the terminal:
    Failed to connect to bus: No such file or directory

    what step should I take next?

    1. Can you run the command: export XDG_RUNTIME_DIR=/run/user/`id -u` and enable the autostart command again.

  3. Is possible to run multiple client simultaneously? I have 1 personal and 2 bussiness account, is possible to have all 3 synchronized ?

    1. Yes. You need to create a different configuration file for each instance. For example, you may have:

      Copy the config file from the build directory to each of the above 3, then modify them accordingly.

      Initialize each with:

      onedrive –synchronize
      onedrive –confdir ~/.config/onedrivebusiness1 –synchronize
      onedrive –confdir ~/.config/onedrivebusiness2 –synchronize

      Start each one from the command line, or if from rc.local with something like:

      sudo -u yourusername /usr/local/bin/onedrive –monitor 2>1 > /dev/null &
      sudo -u yourusername /usr/local/bin/onedrive –confdir ~/.config/onedrivebusiness1 –monitor 2>1 > /dev/null &
      sudo -u yourusername /usr/local/bin/onedrive –confdir ~/.config/onedrivebusiness2 –monitor 2>1 > /dev/null &

    2. Yes it is possible – refer to the following for assistance:

  4. Very informative and descriptive article. It took me a few, but Onedrive is up and running without any issues thanks to your post!!

  5. Hi Damien,
    I’m running into an error while trying to install onedrive
    user:~/onedrive$ make

    cc: No such file or directory
    Error: linker exited with status 255
    Makefile:29: recipe for target ‘onedrive’ failed
    make: *** [onedrive] Error 1

    1. Do you have Ubuntu 18.04 Server edition? You probably don’t have the g++ package installed.

      Enter the following command into a Terminal window

      sudo apt install g++

      Then you should be good to go.

  6. Hi all,

    The git clone command is referring to git clone which appears to have been abandoned and contains issues that have not been fixed.

    If you wish to use the latest code which contains numerous fixes and enhancements you need clone from here:

    @Ren – Your issue is fixed in the updated branch – it is a coding defect as to why it does not work
    @Honza – Yes it is, you need 3 separate configuration files / config directories but no issue in doing that.

    1. Hi @abraunegg
      This git is indeed great. I am using it to sync my onedrive account, which has a fair large amount of files (~150k), and the sync is a bit slow. Is there any way of boosting it somehow?

      1. I would suggest that you ensure you are using the latest version (2.3.3) or later as some performance enhancements were included in the last few releases.

        Also – monitor the github site for known issues and current WIP branches for fixes

  7. I get and error when I do the Configuration part. When I run “cp ~/onedrive/config ~/ .config/onedrive/config” I get the following error: cp: target ‘.config/onedrive/config’ is not a directory

    Any help you can propose? Thanks a lot!

    1. @Gert Kruger There is a space too much in the command, it should read “cp ~/onedrive/config ~/.config/onedrive/config”

  8. Hi Damien,
    I followed your instructions and onedrive was working and syncing fine. Then I changed my microsoft account password.
    I now get an authentication error:

    “error_description”: “AADSTS70000: The user could not be authenticated as the grant is expired. The user must sign in again.\r\nTrace ID: 335b3c36-b284-41e0-86a1-b2fa77f52700\r\nCorrelation ID: 251bfd43-68fa-455e-bda0-987a3c6938cc\r\nTimestamp: 2019-01-27 08:13:42Z”

    What command do I use to change my password?

    1. Craig, the onedrive application is using token to communicate with your OneDrive account. It doesn’t store your password. You can go to “~/.config/onedrive” folder and remove the “refresh_token” file (optionally the sqlite file too). If you want, just move them to another location (instead of deleting them). Then run “onedrive” command again and it should prompt you to reauthorize access to your OneDrive account.

  9. Hi Damien,
    I renamed the “refresh_token” and sqlite files, ran onedrive and when I entered the URI response provided by microsoft I got the following message:

    “Delta link expired, resyncing
    std.json.JSONException@/usr/lib/gcc/x86_64-linux-gnu/7/include/d/std/json.d(551): JSONValue is not an object”

    I did a bit of reseach that resulted in running the “onedrive –resync –verbose” command, then all my files started sycning.

    Everything is now all good. Thank you very much for your help – people like you make the world a better place.

    Craig Taylor

  10. $ sudo systemctl –user enable onedrive
    Failed to connect to bus: No such file or directory

  11. Thanks for this, and thanks to abraunegg for the update! This works beautifully.

    However, how do I avoid re-uploading files I’ve deleted from OneDrive itself but are stored on the local machine?

  12. All is well until after starting onedrive and copy the onedrive url after logging in.
    After pasting and enter it saysL:
    Invalid uri. Could not initialize onedrive API

  13. Thanks Damien. I was able to get OneDrive working. I used the following repo.

    I had only one issue:
    Error: Failed to connect to bus: No such file or directory

    I tried your suggested cmd: export XDG_RUNTIME_DIR=/run/user/`id -u`

    I still get the same error. Since this is to only enable autostart on login. I am fine if I have to manually start the service.

    It’ll help if you can suggest on how can I deal with the error or what are the steps I can follow to manually start the service. (I guess I should use onedrive –synchronize. Correct me if I am wrong)

    Thank you for the detailed article. This was the last thing I was looking for to completely move from Windows to Ubuntu.

    1. Instead of using systemd, you might just want to add the code onedrive --synchronize to your startup application list.

  14. Hello Damien, I quite new in Linux, and I was installing OneDrive and after pasting the url of the white blank page into the terminal it says:

    “–synchronize or –monitor missing from your command options or use –help for further assistance”

    So the –synchronize command doesn’t work.

    What should I do?

  15. Hell again,

    “monitor_interval: the time interval between sync operations.

    Once you have made the changes, save and restart onedrive.”

    Restart how?
    This info needs to be added.

    1. To enable the onedrive service

      systemctl –user enable onedrive

      To start the service

      systemctl –user start onedrive

      To restart the service

      systemctl –user restart onedrive

  16. Hi Damien

    I have tried this method/tool out and got semi-good results. It is syncing the folders and files I had on my OneDrive, EXCEPT it will not sync OneNote files. They are just ignored.

    Am I out of luck here? Or is there something I can do to enable OneNote….which is my primary objective in getting OneDrive to sync.


  17. Hi Damien

    I ran `onedrive –resync –synchronize -v+` and found some entries like the following:
    This item type (Patrick’s Woodshop) is not supported

    Since this item is a OneNote file I am concluding that I will not be able to sync OneNote files with this tool.
    Do you have any further insight?

    Thank you!

    1. The onedrive client uses the OneDrive API, where as OneNote uses a totally different API as per – using the ‘onedrive’ client to sync OneNote files is not possible.

  18. Hi Damien!

    I’m using Linux Mint and ran into the same problem as Dante did – neither the synchronize nor the monitor commands are available. I got

    –synchronize or –monitor missing from your command options or use –help for further assistance

    No OneDrive sync will be performed without either of these two arguments being present

    What do I do to rectify this?

    1. It is best you refer to the readme to assist with commands and configuration:

      1. Alex, what do you mean by this? Please elaborate.
        Is there any awas –synchronize or –monitor can be added to our command options, or something like that?

        1. @silas
          You need to refer to for the usage of the application.

  19. Thanks for this. One point though …

    This section:
    cd onedrive
    sudo make install

    … didn’t work for me out the box on Ubuntu 19.04. I had to do this instead:
    cd onedrive
    sudo make install

  20. Does anyone know how to sync additional folders (OneDrive – Company) into this OneDrive CLI? I’m only available to sync personal files within OneDrive, which renders it almost useless.


    1. This is supportes in my version. Refer to for details

  21. This may sound like an idiot’s question but does the client for linux encrypt data in transit like the Windows onedrive client does?

  22. Hi Damien,

    When I run the command “onedrive”, I didn’t get the link to verify my account info. Instead, it gave “Delta link expired, resyncing” and some other staff (it ends with “Segmentation fault (core dumped)”). Do you happen to know what this might be?


    1. If you have any issues with the client, rather than posting a comment here – please post an issue ticket here –

      1. Thank you! I got it fixed somehow. It seems the reason is that I installed before and had verified my onedrive account back then.

  23. Great for users with small OneDrive but I get error message in the middle of synchronizing. Enabling verbose mode I get:

    Downloading: Pictures/Camera Roll/20151017_192622.jpg
    sync.SyncException@src/sync.d(182): HTTP request returned status code 429 (Too Many Requests)
    0x55990725491a ???
    0x55990724a002 ???
    0x559907249a72 ???
    0x55990739d8be ???
    0x55990739da2e ???
    0x55990739ddea ???
    0x55990739da2e ???
    0x55990739dbc0 ???
    0x559907248ea3 ???
    0x7f6662f1cb96 __libc_start_main
    0x559907240c99 ???
    0xffffffffffffffff ???
    onedrive.OneDriveException@src/onedrive.d(396): HTTP request returned status code 429 (Too Many Requests)
    0x55990724e9b3 ???
    0x55990724df3d ???
    0x55990724c829 ???
    0x55990725556d ???
    0x5599072551d8 ???
    0x55990725446c ???
    0x55990724a002 ???
    0x559907249a72 ???
    0x55990739d8be ???
    0x55990739da2e ???
    0x55990739ddea ???
    0x55990739da2e ???
    0x55990739dbc0 ???
    0x559907248ea3 ???
    0x7f6662f1cb96 __libc_start_main
    0x559907240c99 ???
    0xffffffffffffffff ???

    1. This is a known bug in ‘skilion’ codebase which is fixed in my fork –

  24. sergey@sergey-inspiron-5770:~$ git clone
    Cloning into «onedrive»…
    remote: Enumerating objects: 62, done.
    remote: Counting objects: 100% (62/62), done.
    remote: Compressing objects: 100% (41/41), done.
    remote: Total 2698 (delta 39), reused 39 (delta 21), pack-reused 2636
    Получение объектов: 100% (2698/2698), 1.66 MiB | 1.84 MiB/s, готово.
    Определение изменений: 100% (1798/1798), готово.
    sergey@sergey-inspiron-5770:~$ cd onedrive
    sergey@sergey-inspiron-5770:~/onedrive$ make
    make: *** No targets set and no makefile found. Stop.

  25. Hi there!
    I still get the trouble with the ./configue && make && make install. It did synchronized but I cannot set up the configuration.

    see the error below:

    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… no
    checking for dmd… dmd
    checking for curl… no
    configure: error: in `/home/taotoa/onedrive’:
    configure: error: The pkg-config script could not be found or is too old. Make sure it
    is in your PATH or set the PKG_CONFIG environment variable to the full
    path to pkg-config.

    Alternatively, you may set the environment variables curl_CFLAGS
    and curl_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

    To get pkg-config, see .
    See `config.log’ for more details

    1. checking for a BSD-compatible install… /usr/bin/install -c
      checking for pkg-config… no

      This is the problem. I had the same error messages, and was confused by this red herring:

      “checking for curl… no”

      Especially since “curl” was on my ubuntu 18.04 install.

      The solution:

      sudo apt install pkg-config

      At least it worked for me. Good luck!

      1. Thanks! This is the one part I was missing. All works for me know. Thanks to the maketecheasier folks for the article and fixes and to Jim for the pkg-config help.

  26. Thanks for the write-up!

    One small thing – I had to run `./configure` before being able to run `make`.

  27. Hi!
    Thank you very much for this useful page. In my case, the manual sync works but not as a service. When running:
    systemctl status onedrive@user.service
    I get:
    jun 25 11:36:28 onedrive[14733]: There was a problem in accessing the Microsoft OneDrive service – Internet connectivity issue?
    jun 25 11:36:28 onedrive[14733]: Cannot initialize connection to OneDrive
    I’ve edited the file onedrive.service and I’ve added the details of the proxy as suggested.
    I’ve also seen in the same folder where onedrive.service is very similar files that I have not edited although they have very similar structure. The files are:
    -rw-r–r– 1 user user 395 jun 25 11:28 onedrive.service
    -rw-r–r– 1 user user 336 jun 7 08:23 ‘onedrive@.service’
    -rw-r–r– 1 user user 268 jun 7 08:23
    -rw-r–r– 1 user user 334 jun 7 08:23 ‘’
    Any suggestion to make the service work as expected and automatically sync all the changes?

    1. You need to pay special attention to how you are activating the user service files. Refer to

  28. I’m running Ubuntu 18.4.2 when I ran sudo snap install –classic dmd && sudo snap install –classic dub I got this error “error: unknown flag `classic'”
    So I tried the instructions for Ubuntu 17 and all appeared to go well until I entered make and got this error “make: *** No targets specified and no makefile found. Stop.”
    I found a post where someone was having problems with make and posted this solution “./configure” I ran it and got this error.
    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0… yes
    checking for dmd… no
    checking for ldmd2… no
    checking for ldc2… no
    configure: error: Could not find any compatible D compiler

    Which looks like it points back to my first error. Any suggestions?

    1. You need to pay special attention to

      The instructions on this website above are not correct and need to be updated

  29. Hi there,

    I’ve downloaded the onedrive files and installed dmd but when I run the “make” command it says “No targets specified and no makefile found. Stop.”

    1. That happens because there is no file named Makefile in that directory. To create that Makefile, you need to execute

      sudo make install

  30. “and grant the app permission to access your account. …. ”
    and how do you do that? Where would I start looking on Onedrive to find something that says grant the app permission?

  31. Thank you, It works properly but I want to uninstall for some reasons. I couldn’t manage that. How can I remove this?

  32. I installed snap, but it turned out to be snapd, instead.
    The rest went smoothly.
    Thank you.

  33. I am using a second internal HD to hold my OneDrive folder:

    sync_dir = “/media/z0rk/02/OneDrive

    Should this drive become unavailable (fail/not mounted) what would happen if onedrive is configured to monitor/synchronize changes every 5 minutes? Will it convert back to sync_dir = “~/OneDrive”? I believe not. Could somebody please confirm?


    1. @z0rk
      Best to submit support questions here rather than this website.

      To answer your question, you can utilise this method:

      Add a ‘.nosync’ file to the folder which you mount the drive to, then configure ‘check for nosync’ to prevent syncing if this drive becomes unavailable

  34. Fantastic article, however my onedrive only ran a synch on the initial config.
    now when i run it, it refuses to communicate with the following verbose snips which i think is RC.
    My ubuntu is behind a corporate proxy but my env is set and i can browse an curl OK.
    Initializing the OneDrive API …
    Cannot connect to Microsoft OneDrive Service
    Reason: Failure when receiving data from the peer on handle 55A40202BDE0

    1. @John
      You have not configured proxy correctly – refer to

  35. Thanks for the great tutorial!
    I use CentOS 7 and realized that the section for Fedora applies quite well, but misses the instruction to also install ‘gcc’. Maybe this is included in Fedora out of the box. Nevertheless, it might be helpful to also add ‘gcc’ to the list of packages that need to be present.
    In addition, I realized that I needed to enter the ‘dmd’ mode(?) on my Linux shell:
    $ source ~/dlang/dmd-2.088.0/activate
    Only after that ‘./configure’ and the ‘make’ commands ran successfully. Might be worthwhile to mention the ‘source …/activate’ command and maybe the ‘deactivate’ call at the end explicitly within your awesome tutorial.

    1. @slowjoe007

      This website’s install details are incorrect – please refer to the following:

  36. Works fine, but onedrive limit is 5GB so when the onedrive reached 3.9 GB and i am putting a 2 GB file in OneDrive folder and it starts syncing, beacuse there is no space left in onedrive it doesn’t tell that there is no space and it always try to upload file and wastes the bandwidth.

  37. Since I use OneDrive for Business, this version didn’t work for me.
    I switched to using this fork:
    Handles syncing shared libraries.

  38. I am getting an unknown key in config file: download_only

    I did change this setting, but after reversing, I still get the same error. I can not even synchronize

    1. @Carlos
      Do not seek support on this website. Please open a new issue for assistance here:

  39. Thank you for this structured document. I’m using this client to backup my Jenkins configurations. I would like to run this in a mode where even if my local file is deleted , I would not wont it to reflect on my OneDrive cloud. This is so that in-case my local directory gets wiped out, I can still download the files via OneDrive. Is this feature possible ?. I’ve tried by setting the “upload-only” and “no-remote-delete” in ~/.config/onedrive/config to true but unfortunately it did not solve the problem. Please let me know what can be done.

    1. @carmal shaktan
      Do not seek support on this website. Please open a new issue for assistance here:

  40. I’ve been using Manjaro as of late, and loving it. I usually us terminal for most everything but decided to try useing pamac-manager with AUR and SNAP enabled. It installed all the dependencies for me. Works great and I now have easy access to the files I keep on onedrive.

  41. Hello,
    I ran onedrive –synchronize –resync successfully. All files and folders were said to be downloaded, but I only see empty folders in my local ~/onedrive. What has happened actually?

    1. @Jaher Pruky
      Do not seek support on this website. Please open a new issue for assistance here:

  42. Thank you (although I shold’ve thanked last year)

    Ever since the realease of Ubuntu 18.04 I’ve been changing the OS version (full reinstall) and this is one of the first tools I install right away. Just did it again on 19.10 and it’s working like a charm, as always. Thank you again

  43. Please can you update your website / document to remove all links to ‘Skilion’ version – this repo is unmaintained and is defunct.

    Also, your Ubuntu 18.x instructions are wrong. Please refer to

  44. I am trying to get this to work. I am new to Linux and compiling
    I get the following error:
    :~/onedrive$ ./configure
    checking for a BSD-compatible install… /usr/bin/install -c
    checking for pkg-config… /usr/local/bin/pkg-config
    checking pkg-config is at least version 0.9.0… yes
    checking for dmd… dmd
    checking version of D compiler… 2.090.0
    checking for curl… no
    configure: error: Package requirements (libcurl) were not met:

    No package ‘libcurl’ found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.

    Alternatively, you may set the environment variables curl_CFLAGS
    and curl_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.

  45. Hi,
    I followed the instruction in the “Configuration” part, but now everytime I try to do something it says:
    “Configuration file has errors – please check your configuration”
    Although the config file is in the /.config/onedrive directory
    What did I do wrong? Thank you!

  46. Well after trying out 7 different methods by other people including the abandoned onedrive-d and skillion, I hope my drive is finally working. Thank you for a well-written post.

  47. I don’t understand how the instructions of selective syncing the folder…. can someone help me with a little more detailed instructions??? Like how in creating the sync_list and creating the path (what path????)

    Does it sync only one way or both ways????

    Sorry, for any troubles. I’m new with this system :(
    Thanks in advance

Comments are closed.