Skip to content

Instantly share code, notes, and snippets.

@starlinq
Last active July 16, 2024 13:37
Show Gist options
  • Save starlinq/0f98c6d9339497bb8ac42d67f66f60eb to your computer and use it in GitHub Desktop.
Save starlinq/0f98c6d9339497bb8ac42d67f66f60eb to your computer and use it in GitHub Desktop.
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.

@GalaxiumNation
Copy link

Sorry, got it :)

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