Step-by-Step: How to configure Ubuntu Linux to utilize Microsoft OneDrive.

Microsoft OneDirve is quite convenient for making your important files and folders readily available on any computer.  Microsoft does not provide a native desktop sync application for OneDrive for the Linux operating system.  Luckily, the open source community has a solution.  Rather than using the clunky OneDrive web interface to access your files and folders, it is now possible to have them automatically synchronize to your Ubuntu Linux workstation.

Prerequisites:  You must have administrator access to the target computer.  You must have Internet access on the target computer. 

 


 

1.  Launch the Ubuntu Terminal application.   

 

 

If there is no launcher icon already on your launcher bar at the left-hand edge of the screen, click on Activities and search for Terminal in the search box.

 

 

2.  Enter the command sudo apt install git -y

 

 

Installation progress is displayed in the terminal.

 

 

3.  Now we download the installation files.

 

git clone https://github.com/abraunegg/onedrive

 

When the download is completed you now have a new folder inside your home folder named onedrive.

 


 

 

4.  There are a number of dependencies that must be met.  Enter each of the following commands in the terminal. 

When prompted to continue, enter .

 

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
sudo apt install curl
curl -fsS https://dlang.org/install.sh | bash -s dmd
sudo apt install libnotify-dev

 

 

For the purposes of this tutorial, I will not make a screen shot of the execution of each command.  Enter each in turn.

 

5.  Now activate the dmd package installed in step 4  As the dmd package is updated over time, you will have to change the /dmd-2.093.0/ reference in the command below to the current version folder name that actually exists in your ~/dlang folder.  As of the writing of this tutorial, 2.093.0 is the latest version.

 

source ~/dlang/dmd-2.093.0/activate

 

dmd has been successfully activated if you see the command prompt is now prefixed with (dmd-2.093.0)

 

 

6.  Now we compile the project.  Enter the following commands:

 

cd onedrive
./configure
make clean; make;
sudo make install

 

 

 

 

7.  Now to configure the OneDrive connection.  Enter the command onedrive   A URL link will be generated for your to open in your web browser.  Right click on the link in Terminal and select Open Link.

 

 

Your web browser will open to Microsoft's log on page.  Enter your CSM email address and click on the Next button.

 

 

You are redirected to the CSM log on page.

 

 

Enter your CSM multipass password and click the Sign in button.

 

 

If you are enrolled in CSM's multi-factor authentication service, you are prompted with the DUO authentication prompt.  Use the authentication method of your choice.  If you are not a multi-factor authentication user, you will not see this screen.

 

 

You are notified of the access that the OneDrive client for Linux will have if you accept, click on the Accept button.

 

 

After accepting, you are presented with a blank web page.  You must select the URL populated in the address line and copy it.  Click your mouse somewhere in the address line, then press CTRL+A to select all the text in the line.  then right-click your mouse on the highlighted text and select Copy.

 

 

Switch back to your terminal session and paste the copied URL on the line beginning with Enter the response uri: and press the Enter key.

 

 

If successful you are notified.  The OneDrive client for Linux is now authorized to access your files and folders stored on OneDrive.

 

 

8.  Using the Ubuntu File Manager, navigate to ~/onedrive and look for the file named config.  Right-click your mouse on the file and select Copy.

 

 

Now go back up one level to your Home folder and press CTRL+H so that the file manager shows the hidden files and folders.  Hidden files and folder in Linux always begin with the "period" character.

 

Before pressing CTRL+H

 

 

After pressing CTRL+H

 

 

Now navigate with the file manager to the ~/.config/onedrive folder and paste the config file there.

 

 

9.  Double-click on the config file to open it in the Gedit text editor.

 

 

You will modify a few lines in the configuration file to customize how the OneDrive client for Linux behaves.

Find the line # sync_dir = "~/OneDrive"

Remove the # symbol from the beginning of the line to enable the setting.  This will create a folder named OneDrive inside your Home folder to allow the contents of your OneDrive account files to be synchronized there.  Don't confuse this with the folder named onedrive which already exists there.  The onedrive contains the installation files for the OneDrive Client for Linux and you will delete it when the install process is completed.

Next, find the line # skip_file = "~*|.~*|*.tmp"

Remove the # symbol from the beginning of the line to enable the setting.  This setting tells the system not to synchronize temporary files.

Your file should now look like this:

 

 

Save and close the config file.

 

 

10.  To check your OneDrive for Linux client settings, execute onedrive --display-config

You can see the sync_dir and skip_file changes that we made earlier in the config file.

 

 

11.  Now we do a dry run to see what would be synchronized.  

Enter the command onedrive --synchronize --dry-run

The enables us to ensure things are configured properly before doing an actual sync. 

You can see what files and folders will be synchronized and if any error messages are generated.

 

 

12.  If you're satisfied that your configuration is correct, now do an actual sync.

Execute onedrive --synchronize

As this is the initial synchronization, it may take some time to complete.  Progress is displayed.

 

 

After the initial synchronization is complete, you can open up the Ubuntu file manager and see your OneDrive files now located in your ~/OneDrive folder.

 

 

For the sake of comparison, you can log on to your OneDrive account at oofice365.com. 

Compare the contents in the screen shot above with the screen shot below. 

Obviously, your contents will differ, but both screens should show the same content.

 

 

13.  Now to configure your system to run the OneDrive client for Linux automatically.

To enable the OneDrive client for linux to run as a service:  systemctl --user enable onedrive

To start the OneDrive client for linux service: systemctl --user start onedrive

If you want to see the log file, use the command:  journalctl --user-unit onedrive -f

 

 

Lastly, you'll create a startup item to launch the service automatically every time you log on to the system.

Click on the Activities link at the top left-hand corner of the desktop.  Enter startup in the search box and then select Startup Applications from the search results.

 

 

In the Startup Applications Preferences dialog, Click the Add button and enter the following:

Name:  Auto start OneDrive Sync Service

Command:  systemctl --user start onedrive

Comment field text is optional.

Click the Add button and then Close.

 

 

The OneDrive client for Linux is now fully configured and will run automatically every time you log on to the computer.


2022.06.03 - Revised - dkearney

2020.07.27 - dkearney