How to Sync Microsoft OneDrive with Linux


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 website under a magnifying glass by DepositPhotos


  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. systemctl –user commands should be run (and will work properly) without sudo

  4. 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:

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

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

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

  8. 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”

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

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

    1. This is a known issue and fixed in my branch

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

    1. Try the command again without sudo. ie

      systemctl -user enable onedrive

  12. 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?

    1. This is a known bug and fixed in my fork – you need to modify your config and resync

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

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

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

    1. I have the same problem

  16. Hi,

    Found a typo;

    onedrive –sychronize >> onedrive –synchronize

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

      1. Thank you!

  18. Hello Damien

    How can you skill multiple folders
    i have tried but it did not work

    thank you

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


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

  21. 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:

  22. Thanks..

    It works!

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

    1. I had the same issue, thanks for posting this

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

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

    1. All traffic is https / tls 1.2 protected

  26. 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. This is a known bug with the skilion version which is fixed in my fork

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

  27. 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 –

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

    1. I had the same issue. Run the following :
      sudo make install

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

  30. Thanks for the write-up!

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

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

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

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

  34. “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?

  35. Apologies. I managed to get it working by following your instructions more closely.

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

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.