Install & Setup OneDrive Client in Ubuntu 24.04 | 22.04

Last updated: April 29, 2024 — 17 Comments

This is a step by step beginners guide shows how to install and setup OneDrive client in Ubuntu 22.04 and Ubuntu 24.04 to sync files between local machine and Microsoft cloud.

OneDrive is a file hosting service by Microsoft. It so far does not have an official app for Linux, but there’s a popular free open-source client works in most Linux. And, here’s the basic how to guide for installing and using it in Ubuntu Linux.

Method 1: Ubuntu 24.04 with default GNOME Desktop only

GNOME 46 introduced onedrive support in its Online Accounts integration. Meaning, Ubuntu 24.04, Fedora 40 Workstation, and other other Linux with the latest GNOME can follow the steps below to get OneDrive integration in file manager.

1. First, press Super (Window Logo) + S to open top-right system tray menu (aka Quick Settings), then click open “Settings” utility.

2. When it opens, navigate to Online Accounts in the left, then click MicroSoft 365 in right. In will open up a web page, and ask to login and grant permissions  to access your onedrive files.

3. After successfully login your account, you’ll see it listed in the settings page. By clicking on it will pop-up the dialog, with option to toggle on/off onedrive access, and button to remove the Microsoft 365 account at anytime as you want.

And, you can re-open “Files”, aka Nautilus file manager, and click you account name in left panel to access OneDrive files.

Method 2: for Ubuntu 22.04/24.04 with any desktop environments:

Step 1: Install OneDrive Client:

Option 1: Install it from system repository
The client package is available in most Linux repositories, including Ubuntu.

For Ubuntu users, simply press Ctrl+Alt+T on keyboard to open terminal. and run command to install it:

sudo apt install onedrive


Option 2: Install from third-party repository
OneDrive package in Ubuntu 22.04 and Ubuntu 20.04 repository is old. If you would like to get the latest version, then here’s a third-party repository available.

1. First, click the link below to go to the OBS repository:

2. In that web page, click on Ubuntu logo, select “Grab binary package directly“, then click download the .deb package for your system.

In case you don’t know which Ubuntu version is currently running, open terminal (Ctrl+Alt+T) and run cat /etc/os-release and dpkg --print-architecture commands to tell.

3. Finally, right-click on your Downloads folder and click “Open in Terminal“, and run command in pop-up terminal to install the .deb package.

sudo apt install ./onedrive*.deb

Step 2: Authorize with your OneDrive Account

Before being able to upload or download files, you have to first authorize the app with your OneDrive account.

1. To do so, simply open terminal (Ctrl+Alt+T) and run command:

onedrive

Then, copy the output link url and open in web browser.

2. In the web page, click “Accept” button to grant permissions to access your OneDrive account.

3. After that, the web page will be redirect to a blank page. Just copy the url of that blank page, and paste into the terminal window and hit Enter.

If done successfully, the terminal will output somethings says ‘Application has been successfully authorized‘.

Step 3: Sync files between local folder and OneDrive cloud.

After authorized the app, you can now try running the client in terminal (Ctrl+Alt+T) by running command:

onedrive --dry-run --synchronize

This command will run the client to test the configuration. No files will be downloaded, uploaded or removed! A OneDrive folder will be created (if not exist) in your user home directory for syncing files.

To start syncing files, run command:

onedrive --synchronize

Or use onedrive --synchronize --local-first to upload local files (from user’s OneDrive folder) first then download from cloud.

For choice, you may sync only single folder only, for example “Pictures” sub-folder under OneDrive directory, by running command:

onedrive --synchronize --single-directory 'Pictures'

Or, do uploading local files only via command:

onedrive --synchronize --upload-only

There’s also --download-only command option to only download differences from cloud to local, and --no-remote-delete to NOT remove files that previously synced but later manually deleted.

Step 4: Sync files automatically

If everything goes OK, you may also start OneDrive as systemd service, so it does the file sync between cloud and local folder automatically.

To do so, simply run command in terminal (Ctrl+Alt+T) to enable the service:

systemctl enable --user onedrive

Then, start it by running command:

systemctl start --user onedrive

Finally, check the service status by running command systemctl status --user onedrive.

Once the service is in active running status, try making difference in either local or cloud OneDrive folder, then check in another side to see if it works.

Step 5: Config OneDrive client

If the default sync options do not meet your need, then, run command to copy example config file to local folder:

sudo cp /usr/share/doc/onedrive/config ~/.config/onedrive/

Then, change the ownership from root to your user:

sudo chown $USER:$USER ~/.config/onedrive/config

Finally, either open file manager (press Ctrl+H to view hidden files/folders), navigate, and click edit the file. Or, run command:

gedit ~/.config/onedrive/config

For Ubuntu 23.10+, replace gedit with gnome-text-editor. For non-GNOME Desktop, replace it with your text editor, or use nano command line editor works in most desktops.

When file opens, un-comment (remove # at the beginning) to enable any option and change its value as you want, such as sync folder, exclude files/folders, upload only or download only, and more, and finally save the file.

Finally, run command systemctl restart --user onedrive to restart service to apply the changes. For more about how to use OneDrive client, see the official docs.

Uninstall OneDrive:

If you don’t to use the client anymore, open terminal (Ctrl+Alt+T) and run command to stop and disable the service:

systemctl disable --now --user onedrive

Then, remove the client package by running command:

sudo apt remove --autoremove onedrive

For choice, you may clear the leftovers by deleting them via commands:

sudo rm /etc/logrotate.d/onedrive
rm -R ~/.config/onedrive

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

17 responses to Install & Setup OneDrive Client in Ubuntu 24.04 | 22.04

  1. Thanks, Ji!
    Your tutorials are simply the best.

  2. thanks for sharing. Lovely Job.
    Best wishes

  3. Thanks for your tutorials ! It helps a lot

  4. Hi Ji, thank you for your tutorial, but I have one problem. After installing one drive client in Ubuntu 23.10, copy the link to authorize the app in microsoft, I sign into my account and nothing happens. The page goes blank and stays there. Any idea?

  5. Hi Ji m,

    the tutorial was really helpful, thanks!
    But I have a problem, the sharepoint taht I share with my colleagues do not sync, I went into the options and tried:
    sync_business_shared_folders = “true”
    but it didn’t do anything. Do you know how I can proceed?

  6. Thanks for this tuto. Very helpfull !
    The next step is to have the Ubuntu 24.04 Onedrive automatically mounted at startup.
    How to do this ? What is the CLI to use ?

  7. Are there any known issues using authenticator code?

  8. Thank you very much for this explanation, it was really helpfull.

  9. Thanks so much Ji for the nice tutorial. Very helpful!

  10. I get the error while i try to copy back the URL and run it in terminal window.

    Below is the transcript of the error received.

    *****************************************************
    Authorize this app visiting:

    https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=22c49a0d-d21c-4792-aed1-8f163c982546&scope=Files.ReadWrite%20Files.ReadWrite.all%20Sites.ReadWrite.All%20offline_access&response_type=code&redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient

    Enter the response uri: https://login.microsoftonline.com/common/oauth2/nativeclient?code=M.C507_BAY.2.U.1ea7a6ad-49a2-c35f-180b-4a61f716413d
    onedrive.OneDriveException@src/onedrive.d(874): HTTP request returned status code 400 (Bad Request)
    {
    “correlation_id”: “fa3e5e70-8931-494a-9564-651827c53549”,
    “error”: “invalid_grant”,
    “error_codes”: [
    70000
    ],
    “error_description”: “AADSTS70000: The provided value for the ‘code’ parameter is not valid. Trace ID: b58b74c5-520c-4a60-a835-6bccf3343b00 Correlation ID: fa3e5e70-8931-494a-9564-651827c53549 Timestamp: 2024-08-21 06:01:57Z”,
    “error_uri”: “https:\/\/login.microsoftonline.com\/error?code=70000”,
    “timestamp”: “2024-08-21 06:01:57Z”,
    “trace_id”: “b58b74c5-520c-4a60-a835-6bccf3343b00”
    }
    —————-
    ??:? [0x55c101f629d9]
    ??:? [0x55c101f61cb5]
    ??:? [0x55c101f62b65]
    ??:? [0x55c101f60f58]
    ??:? [0x55c101f608c5]
    ??:? [0x55c101f6e7a8]
    ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7faad3b059db]
    ??:? _d_run_main2 [0x7faad3b057ee]
    ??:? _d_run_main [0x7faad3b0565d]
    ??:? __libc_start_main [0x7faad36ee082]
    ??:? [0x55c101f395ed]

    Could you please advice where i went wrong

  11. Straightforward and clear Article.
    Thanks

  12. Hi,

    I just wanted to take a moment to sincerely thank you for the solution you provided. Your advice was exactly what I needed, and it worked perfectly. I’m really grateful for the time and effort you took to help me out.

    Thanks again, and I truly appreciate your support!

    Best regards,

  13. amazing job

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*