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.
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:
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
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:
sudo make install
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:
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:
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.
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
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!