OneDrive is Microsoft’s cloud-based storage offering, and even though it is naturally suited to the Windows platform, it will connect with Linux-based machines with little effort. There are a number of ways to do this, and this is where the onedrive script comes into play.

OneDrive

Onedrive is a CLI-based client that allows you to sync quickly and easily with OneDrive. In order to install onedrive, first you need to install some dependencies and set up git, unless you already have it. Head to the Terminal and enter one of the following. For Ubuntu: If you are using Ubuntu 18.04 or newer, use snap to install dmd: If not: For Fedora: Arch Linux:

Installation

After installing the dependencies, fetch the files with git: And compile and install it: After you have done this, now you need to authorize onedrive with Microsoft so it can access your account. Simply enter the following in the Terminal: And it will prompt you to visit the URL to get authorization.

Log in to your OneDrive account, and grant the app permission to access your account.

Once this is done, you will be presented with a blank white page. Copy the URL and paste it into the Terminal at the prompt.

This will complete the setting up. To start synchronizing OneDrive to your local folder, run Onedrive will start downloading all your files in the cloud to your local folder. Alternatively, you can run: to get it to monitor your local folder for changes.

Configuration

You can find the “config” file at the onedrive git folder. To make it active, move it to the “~/.config/onedrive/” folder. Open the config file. There are three options that you can configure: “sync_dir” and “skip_files.”

sync_dir: the location to store your OneDrive files. All files placed in/removed from this folder will be synced to the cloud. skip_files: the file type (or file pattern) that won’t be synced. monitor_interval: the time interval between sync operations.

Once you have made the changes, save and restart onedrive. At any time, you can check your configuration with the command:

Sync List

If you prefer to use selective sync rather than sync the whole OneDrive folder, you can create a file named “sync_list,” and place it in the “~/.config/onedrive” folder. Inside the file add the relative path (from the synced OneDrive folder) to the files/folders you want to sync.

Starting onedrive at login

By default, onedrive doesn’t start when the user logs in. To get it to run automatically when you log in, you can add onedrive –monitor to your startup application. Now your OneDrive will sync with your Linux system. How do you sync OneDrive to your setup, and do you prefer other tools? Let us know in the comments section below. This post was updated in March 2019 with a working repository. Image credit: Microsoft OneDrive