OneDrive, Microsoft’s cloud storage service is a pretty popular offering when it comes to cloud storage services. OneDrive enables us to access our files anytime, anywhere, on all our devices. However, there is one big caveat – no official Linux client is available. Therefore, Linux users have to rely on the web version (which does not provide syncing), or on unofficial clients. There used to be a working unofficial client named onedrive-d, however, it is no longer maintained. Having said that, there is another unofficial OneDrive client appropriately named onedrive by GitHub user skilion. It has support for manual and automatic sync, real-time file monitoring and resumable uploads. Although the set up involves some tinkering and using the command line, it works well enough for daily usage and does not pose problems. So, if you are looking to sync your OneDrive data with your Linux computer, here’s how to do it:
Note: This program has been tested under Linux Mint 18. These instructions will work unmodified with Ubuntu 16.04. While getting it to work with other distributions is possible, we haven’t covered it in this article.
Installing OneDrive on Linux
Open the Terminal, and run the following commands to install the prerequisite software
sudo apt-get install libcurl4-openssl-dev libsqlite3-dev build-essential git
After the installation is complete, run the following commands to install the compiler for the D programming language:
sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list wget -qO - http://dlang.org/d-keyring.gpg | sudo apt-key add - sudo apt-get update && sudo apt-get install dmd-bin
We will now download and install the onedrive software. In your Home directory, download the source code using the following command:
git clone https://github.com/skilion/onedrive.git onedrive_code
Now, compile and install the software:
cd onedrive_code make sudo make install
And you are done.
Configuring Your OneDrive Account
To configure your OneDrive account for the first time, open the Terminal, and run
onedrive. You will see a prompt with a URL like this:
Simply copy this URL, and enter it in your web browser of choice. You will be asked for your Microsoft account and password. Once entered, you will get the following screen:
Select Yes here, and copy the URL that appears on the following screen:
Now paste this URL in your Terminal window, and press Enter. You will notice that it automatically starts syncing your OneDrive account with the
Onedrive folder in your home directory. If you have several gigabytes of data stored in your OneDrive account, be patient because this is going to take a while.
Whenever you want to sync your local storage with your OneDrive account on Linux, simply run the command
onedrive from your terminal. As a demonstration, I deleted some images from my OneDrive storage using the web app. On my Linux system, I created a text file in the
Onedrive folder. Running the command
onedrive gives me the following result:
Setting Up Automatic Sync
If you wish to automatically keep your OneDrive account in sync, instead of running the command manually every time, you can enable the systemd service. In a terminal, run:
systemctl --user enable onedrive systemctl --user start onedrive
There is a caveat here. Adding or removing files from your local filesystem reflects the changes in your OneDrive account almost instantly. However, the other way round is slightly delayed. This is not a big deal for most people, but can be a problem if you transfer a lot of files regularly.
If you are not sure whether or not a certain file synced or not, you can check the logs. To do that, run:
journalctl --user-unit onedrive -f
Excluding Files And Folders From Syncing
Let’s say you have a folder filled to the brim with HD videos in your OneDrive account, and you want to avoid syncing that, as it will take up significant bandwidth and space. Maybe you also want to avoid syncing disc images (.iso files). To do this, open the file
~/.config/onedrive/config using your favorite text editor, and modify the
skip_dir sections accordingly:
skip_file = ".*|~*|*.iso" skip_dir = ".*|Videos"
If you are running the sync service, then you need to turn it off first:
systemctl --user stop onedrive
After that, run onedrive with the resync option:
After this, you can re-enable the sync service:
systemctl --user start onedrive
Use OneDrive Seamlessly With Linux
Another good Linux OneDrive client to consider is rclone. While it only offers manual sync, it has certain additional features not present in onedrive, such as support for simultaneous, multiple cloud accounts, including, but not limited to OneDrive, Google Drive, Dropbox, Amazon S3 and Yandex. You can get rclone here.
Well, that’s how you can sync a Microsoft OneDrive account with Linux. Do let us know how it works for you. If you are having problems setting it up, feel free to ask us a question in the comments section below.