Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Sync Microsoft OneDrive with Ubuntu 18.04 and 20.04 (64 bit)
layout title tags date
post
How to Sync Microsoft OneDrive with Ubuntu 18.04 and 20.04 (64 bit)
ubuntu-18.04, ubuntu-20.04
2020-04-23

There are many instructions to syncronize your files with OneDrive cloud-based storage in Linux. However they typically address multiple Linux distributions that often causes a confusion or an use of some commands which have not been actually tested before publishing. This instruction is for Ubuntu 18.04 and 20.04 (64 bit) only.

In order to install onedrive, first you need to install some dependencies and set up git.

Let us open the Terminal application and enter the following:

sudo apt install build-essential
sudo apt install libcurl4-openssl-dev
sudo apt install libsqlite3-dev
sudo apt install pkg-config
sudo apt install git

Lets us move to Downloads directory

cd ~/Downloads

DMD compiler installation

Ubuntu 18.04

Some instructions recommend using snap to install some dependencies, for example here:

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

I tried that and found that after such installation some dependencies are not met!

So I recommend you to install those dependencies using classical method like this:

sudo wget https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
sudo apt-get update --allow-insecure-repositories
sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
sudo apt-get update && sudo apt-get install dmd-compiler dub

Ubuntu 20.04

We download the 64-bit package from

wget http://downloads.dlang.org/releases/2.x/2.093.1/dmd_2.093.1-0_amd64.deb

and install it at system level

sudo dpkg -i dmd_2.093.1-0_amd64.deb

Then we clone the required repository files with git:

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

Then compile and install it:

cd onedrive
./configure
make
sudo make install

The next step, you need to authorize onedrive with Microsoft so it can access your account:

onedrive

Copy the web address appeared in the terminal window right after Authorize this app visiting:, then open any web browser and paste it into the web browser address line.

Log in into your account and grant the application permission to acess your account.

Wait for response ...

Then copy and paste the web address of response into corresponding part of the terminal window with prompt Enter the response uri:.

Now the installation has been done.

Before syncronization, let us create a onedrive directory for current user

mkdir -p ~/OneDrive

and copy a configuration file into default directory

cp config ~/.config/onedrive/config

Now we can leave the installation directory

cd

It is a time to check our current configuration

onedrive --display-config

You will see something like this

onedrive version                       = v2.4.0-25-g7f267a5
Config path                            = /home/yourcurrentusername/.config/onedrive
Config file found in config path       = true
Config option 'check_nosync'           = false
Config option 'sync_dir'               = /home/yourcurrentusername/OneDrive
Config option 'skip_dir'               = 
Config option 'skip_file'              = ~*|.~*|*.tmp
Config option 'skip_dotfiles'          = false
Config option 'skip_symlinks'          = false
Config option 'monitor_interval'       = 45
Config option 'min_notify_changes'     = 5
Config option 'log_dir'                = /var/log/onedrive/
Config option 'classify_as_big_delete' = 1000
Config option 'sync_root_files'        = false
Selective sync configured              = false

For one time sync, run

onedrive --synchronize

or if you want to monitor your OneDrive storage for changes

onedrive --monitor

Do not forget that onedrive doesn’t start when the user logs in. To run automatically when you log in, you can add onedrive --monitor command to your startup application.

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Nov 9, 2020

For Ubuntu 18.x, your instructions are not entirely accurate - refer to:

For Ubuntu 20.x - follow the same 18.x x86_64 directions, or use the Ubuntu PPA

@satyanandakar

This comment has been minimized.

Copy link

@satyanandakar satyanandakar commented Nov 16, 2020

In this way, if I install the OneDrive, will it use the storage memory of PC? After changing a data, every time we have to synchronize?

@starlinq

This comment has been minimized.

Copy link
Owner Author

@starlinq starlinq commented Nov 16, 2020

In this way, if I install the OneDrive, will it use the storage memory of PC?

Yes, it will. If you follow my instruction your files will be stored in ~/OneDrive directory

After changing a data, every time we have to synchronize?

To run a sync automatically when you log in, you have to add onedrive --monitor command to your startup application.

@starlinq

This comment has been minimized.

Copy link
Owner Author

@starlinq starlinq commented Nov 16, 2020

For Ubuntu 18.x, your instructions are not entirely accurate - refer to:

For Ubuntu 20.x - follow the same 18.x x86_64 directions, or use the Ubuntu PPA

You did not specify where my instructions are not correct so in my own guess, there are differences in the 'dependencies' section where I could skip some required packages. I have made some changes accordingly.

I have tested the instructions in both Ubuntu 18.04 and Ubuntu 20.04 environments on my computer and they work well (without any issues).

@satyanandakar

This comment has been minimized.

Copy link

@satyanandakar satyanandakar commented Nov 17, 2020

Instead of syncing all the data in OneDrive, can I sync specifically a folder or a file? If so, please tell.

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Nov 17, 2020

you did not specify where my instructions are not correct so in my own guess

Essentially all of this is incorrect:

sudo wget https://netcologne.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
sudo apt-get update --allow-insecure-repositories
sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring
sudo apt-get update && sudo apt-get install dmd-compiler dub

There is zero need to do this, and as per the correct instructions which I linked to, this provides the correct method to install all the dependencies for Ubuntu 18.x. You probably pulled this info from old websites that have old information which is no longer accurate.

@alexarte

This comment has been minimized.

Copy link

@alexarte alexarte commented Nov 19, 2020

I have this issue, " segment violation (core generated " after i paste the URI that i get. Do someone has the same issue?

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Nov 19, 2020

@alexarte
Please use the right code base & the right instructions to install the application: https://github.com/abraunegg/onedrive

You probably running an old version, from a package that has known bugs.

@eloii23

This comment has been minimized.

Copy link

@eloii23 eloii23 commented Jan 8, 2021

Hi @abraunegg,
is it posible to get or create a share link of a file uploeaded to a Business Shared Folder? I tried with --create-share-link but i get ERROR: The requested path to query was not found on OneDrive and also tried --get-file-link but I get File has not been synced with OneDrive:

Please help :(
Best regards!

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Jan 8, 2021

@eloii23
Please follow the correct support process

@eloii23

This comment has been minimized.

Copy link

@eloii23 eloii23 commented Jan 11, 2021

Hi @abraunegg,
yes sorry :( I sent an email to the support account.

Regards!

@MichaelAtGithup

This comment has been minimized.

Copy link

@MichaelAtGithup MichaelAtGithup commented Jan 26, 2021

Thanx @starling (corrected),
that's quite a long instruction and it worked flawlessly for me.
Actually better than many askubuntu instructions did.

I wish more UBUNTU instructions would be done that accurately.
Must say and thanx again.

@starlinq

This comment has been minimized.

Copy link
Owner Author

@starlinq starlinq commented Jan 26, 2021

Thanx @abraunegg,
that's quite a long instruction and it worked flawlessly for me.
Actually better than many askubuntu instructions did.

I wish more UBUNTU instructions would be done that accurately.
Must say and thanx again.

Are you talking about this instruction? This instruction has been compiled by @starlinq (not @abraunegg) :-)

@yannisdran

This comment has been minimized.

Copy link

@yannisdran yannisdran commented Jan 28, 2021

Hi @abraunegg and @starlinq. Thanks both of you for your efforts.

Reading the guide (or reading the -h in cmd), I couldn't find how to unlink or locally delete a folder without affecting the cloud. Is it possible?

Also, I tried the "onedrive --monitor --skip-dir 'folder1' 'folder2' 'folder-3' " command but it still downloads the whole cloud drive except the first folder1. How can I achieve this? or even better, how I can set this up, exactly like the "select folders to sync" in other systems?

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Jan 28, 2021

@yannisdran
Rather than relying on this gist entry, please refer to the user guide on the GitHub site please.

@yannisdran

This comment has been minimized.

Copy link

@yannisdran yannisdran commented Jan 28, 2021

@abraunegg, sorry, I wasn't clear. I meant I was reading the guide on the GitHub for these info before posting here. However, as there isn't any "Discussion" page I didn't want to open an issue, it is merely just a question. That's why I came back in the gist entry to make my question.

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Jan 29, 2021

@yannisdran
Discussions are now enabled.

@adilsonsf

This comment has been minimized.

Copy link

@adilsonsf adilsonsf commented Feb 17, 2021

It really does what it promises. Thanks!
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

@luiscamachocaballero

This comment has been minimized.

Copy link

@luiscamachocaballero luiscamachocaballero commented Mar 8, 2021

I'm using Ubuntu 20.10. Despite the fact, I installed libcurl4-openssl-dev, my system answered:
rbm@hp-omen:~/Downloads$ git clone https://github.com/abraunegg/onedrive.git
Cloning into 'onedrive'...
/home/rbm/libexec/git-core/git-remote-https: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/rbm/libexec/git-core/git-remote-https)

I'd appreciate any help

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Mar 8, 2021

@luiscamachocaballero

Please follow the correct installation instructions - this document is not entirely accurate.

Please follow: https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md

@siddharth-github

This comment has been minimized.

Copy link

@siddharth-github siddharth-github commented Jul 5, 2021

Hi, I installed onedrive on Ubuntu 20 following your instructions and every thing worked for me. However, recently I had to change my password of one drive. How to update this on my local installation as now onedrive --monitor is giving error.

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Jul 5, 2021

@siddharth-github
Please follow the correct support process. Commenting here is not the correct process.

@hanung665

This comment has been minimized.

Copy link

@hanung665 hanung665 commented Jul 27, 2021

Thanks a lot. It works on my Ubuntu 20.4 flawlessly.

@saitejramu

This comment has been minimized.

Copy link

@saitejramu saitejramu commented Jul 29, 2021

not able to authorize this app!!
link to Authorize not working

@abraunegg

This comment has been minimized.

Copy link

@abraunegg abraunegg commented Jul 29, 2021

@saitejramu
Please follow the correct support process. Commenting here is not the correct process.

@rafael-ibanhez

This comment has been minimized.

Copy link

@rafael-ibanhez rafael-ibanhez commented Aug 27, 2021

Thanks a lot!! have been trying to install this for a while now.
The only remark is that authorization only worked on google chrome on my case.
Thank you again

@NUS-Tim

This comment has been minimized.

Copy link

@NUS-Tim NUS-Tim commented Sep 23, 2021

Great tutorial! I finish all without meeting any problem. Thx bro!

@blaqvikin

This comment has been minimized.

Copy link

@blaqvikin blaqvikin commented Sep 24, 2021

Awesome app, thanks mate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment