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:
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
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:
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:
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:
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.
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!
46 comments
Installed succesfully but after syncing first time if I update a file it doesn’t sync with the onedrive.
I have same problem. There are many files weren’t updated. How can i fix it?
It only syncs on bootup or when you run onedrive in a terminal.
Perhaps a script with a timer to run the start command every few mins?
This woked beautifully!
Thank you!
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.
I searched it up and the commands are correct if you remove sudo.
Upvote for Matthew. Please correct this on the page someone.
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.
The ‘skilion’ code appears to have been abandoned and contains many other 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: https://github.com/abraunegg/onedrive
All have to do is to replace the address https://github.com/skilion/onedrive.git to https://github.com/abraunegg/onedrive in the line
git clone https://github.com/skilion/onedrive.git?
If I do that, will it work properly?
I tried that and it didn’t work. I had to completely delete the onedrive package directory and actually go to abraunegg’s onedrive page on git hub
https://www.google.com/amp/s/www.fosslinux.com/8835/how-to-sync-microsoft-onedrive-with-linux.htm%3famp
and follow the ‘build and install’ link. There are several different sets of commands for downloading dependencies depending on your linux variation. I’m running mint 19.2 on a 64 bit machine so I followed
Dependencies: Ubuntu 18.x, Ubuntu 19.x / Debian 9, Debian 10 – x86_64.
Thanks a lot. This tutorial was very helpful.
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.
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.
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
I had the same problem and downloaded and installed the dmd package from https://dlang.org/download.html.
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.
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
Me too now. I got my other problem figured out, but now I have this also.
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
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]
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.
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.
@Bruce
This is possible – please refer to this to assist – https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md#using-multiple-onedrive-accounts
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/
I want to know how to get list of files which present on one drive folder.
the commands to uninstall this dont work, any surgestions please
It works great. THS.
This solves my problem with onedrive
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
Don’t you have an option with user interface?
Hello.
Works fine on Fedora.
Did 1 modification on src/qxord.d
Before: import std.digest.digest;
After: import std.digest;
To activate onedrive service, i used these commands:
XDG_RUNTIME_DIR=/run/user/$UID systemctl –user enable onedrive
XDG_RUNTIME_DIR=/run/user/$UID systemctl –user start onedrive
you did a great job, thanks for all
Then compile and install it – that’s
cd onedrive
NOT
cd oneDrive
Hi,
how can we force the sync of the files ? after a modification/add for example.
Type “onedrive” in terminal…
Super!
Thanks a lot!!!
Works good here!
Only one question::
Is it normal for the installation / configuration to have created 2 folders, one called “OneDrive” (which contains my files) and the other called “onedrive” (where it appears to have the configuration files)?
Thank you all
Installation and configuration on my Linux Mint 18.1 machine seemed to go smoothly, however when I ran it, I got the following output:
graham@graham-minidesktop ~ $ onedrive-d start
Traceback (most recent call last):
File “/usr/local/bin/onedrive-d”, line 33, in
sys.exit(load_entry_point(‘onedrive-d==1.1.0.dev0’, ‘console_scripts’, ‘onedrive-d’)())
File “/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py”, line 473, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py”, line 2843, in load_entry_point
return ep.load()
File “/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py”, line 2447, in load
return self.resolve()
File “/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py”, line 2453, in resolve
module = __import__(self.module_name, fromlist=[‘__name__’], level=0)
File “”, line 969, in _find_and_load
File “”, line 958, in _find_and_load_unlocked
File “”, line 664, in _load_unlocked
File “”, line 634, in _load_backward_compatible
File “/usr/local/lib/python3.5/dist-packages/onedrive_d-1.1.0.dev0-py3.5.egg/onedrive_d/od_main.py”, line 8, in
File “/usr/local/lib/python3.5/dist-packages/click-8.0.0a1-py3.5.egg/click/__init__.py”, line 7, in
from .core import Argument
File “/usr/local/lib/python3.5/dist-packages/click-8.0.0a1-py3.5.egg/click/core.py”, line 91
f”{hint}. Command {base_command.name!r} is set to chain and”
^
SyntaxError: invalid syntax
I don’t know Python so this doesn’t mean much to me.
Anyone know what I’m doing wrong?
You are trying to use / run a defunct + depreciated OneDrive Client. Uninstall anything to do with ‘onedrive-d’ and follow the correct installation instructions as per https://github.com/abraunegg/onedrive/blob/master/docs/INSTALL.md to install the Free OneDrive Client for Linux which I an the developer of.
How can I completely remove this client and it’s dependencies so I can start over with the install process? The uninstall commands didn’t do anything for me..
After I inputted the url of the BLANK web page I get the following – What have i done wrong ?
onedrive.OneDriveException@src/onedrive.d(874): HTTP request returned status code 400 (Bad Request)
{
“correlation_id”: “7e4afaf0-3892-4264-8865-ca771f997132”,
“error”: “invalid_grant”,
“error_codes”: [
70000
],
“error_description”: “AADSTS70000: The provided value for the ‘code’ parameter is not valid.\r\nTrace ID: 24060108-4313-4713-8932-4a32dd710200\r\nCorrelation ID: 7e4afaf0-3892-4264-8865-ca771f997132\r\nTimestamp: 2021-05-20 23:53:16Z”,
“error_uri”: “https:\/\/login.microsoftonline.com\/error?code=70000”,
“timestamp”: “2021-05-20 23:53:16Z”,
“trace_id”: “24060108-4313-4713-8932-4a32dd710200”
}
—————-
??:? [0x55bc4a9499d9]
??:? [0x55bc4a948cb5]
??:? [0x55bc4a949b65]
??:? [0x55bc4a947f58]
??:? [0x55bc4a9478c5]
??:? [0x55bc4a9557a8]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7fe751bef9db]
??:? _d_run_main2 [0x7fe751bef7ee]
??:? _d_run_main [0x7fe751bef65d]
??:? __libc_start_main [0x7fe7517db0b2]
??:? [0x55bc4a9205ed]
How can I choose to sync only particular files and folders? I don’t want to sync my whole OneDrive data, it’s too much.
What is the solution for this : “correlation_id”: “51340f1d-120a-4650-b670-5e827e431367”,
“error”: “invalid_grant”,
“error_codes”: [
70000
],
“error_description”: “AADSTS70000: The provided value for the ‘code’ parameter is not valid.\r\nTrace ID: 241f1e21-8c44-4e33-a4f0-c912130f9402\r\nCorrelation ID: 51340f1d-120a-4650-b670-5e827e431367\r\nTimestamp: 2021-10-27 19:05:40Z”,
“error_uri”: “https:\/\/login.microsoftonline.com\/error?code=70000”,
“timestamp”: “2021-10-27 19:05:40Z”,
“trace_id”: “241f1e21-8c44-4e33-a4f0-c912130f9402”
}
—————-
??:? [0x555e4a72e9d9]
??:? [0x555e4a72dcb5]
??:? [0x555e4a72eb65]
??:? [0x555e4a72cf58]
??:? [0x555e4a72c8c5]
??:? [0x555e4a73a7a8]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7f2e24d099db]
??:? _d_run_main2 [0x7f2e24d097ee]
??:? _d_run_main [0x7f2e24d0965d]
??:? __libc_start_main [0x7f2e248f50b2]
??:? [0x555e4a7055ed]
THX for help
“install Linux they say, It will be fun they say”
I’m a newbie to Linux but would neverteless sync my onedrive data to my secundary linux laptop here.
I have a Linux Cinnamon desktop, i did all the first steps of this tutorial until opening the apt list with Nano.
I get this but nowhere is there a line with DEB in it ????
–2023-03-17 21:24:55– http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list
Resolving master.dl.sourceforge.net (master.dl.sourceforge.net)… 216.105.38.12
Connecting to master.dl.sourceforge.net (master.dl.sourceforge.net)|216.105.38.12|:80… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: http://downloads.sourceforge.net/project/d-apt/files/d-apt.list [following]
–2023-03-17 21:24:55– http://downloads.sourceforge.net/project/d-apt/files/d-apt.list
Resolving downloads.sourceforge.net (downloads.sourceforge.net)… 204.68.111.105
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|204.68.111.105|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://kumisystems.dl.sourceforge.net/project/d-apt/files/d-apt.list [following]
–2023-03-17 21:24:56– http://kumisystems.dl.sourceforge.net/project/d-apt/files/d-apt.list
Resolving kumisystems.dl.sourceforge.net (kumisystems.dl.sourceforge.net)… 2a01:4f8:210:1057::2, 148.251.120.111
Connecting to kumisystems.dl.sourceforge.net (kumisystems.dl.sourceforge.net)|2a01:4f8:210:1057::2|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 100 [application/octet-stream]
Saving to: ‘d-apt.list.1’
0K 100% 3,91M=0s
2023-03-17 21:24:56 (3,91 MB/s) – ‘d-apt.list.1’ saved [100/100]
So atm i can’t say if it works or not cause i’m stuck with the tutorial not matching my results