How to access Dropbox from the command line in Linux

Cloud storage is everywhere in today's multi-device environment where people want to access content across multiple devices wherever they go. Dropbox is the most widely used cloud storage service due to its elegant UI and flawless multi-platform compatibility. There are numerous official or unofficial Dropbox clients available on multiple platforms.

Linux has its own share of Dropbox clients; CLI clients as well as GUI-based clients. Dropbox Uploader is an easy-to-use Dropbox CLI client written in BASH scripting language. In this tutorial, I describe how to access Dropbox from the command line in Linux by using Dropbox Uploader.

Install and Configure Dropbox Uploader on Linux

To use Dropbox Uploader, download the script and make it executable.

$ wget https://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh
$ chmod +x dropbox_uploader.sh

Make sure that you have installed curl on your system, since Dropbox Uploader runs Dropbox APIs via curl.

To configure Dropbox Uploader, simply run dropbox_uploader.sh. When you run the script for the first time, it will ask you to grant the script access to your Dropbox account.

$ ./dropbox_uploader.sh

As instructed above, go to https://www2.dropbox.com/developers/apps on your web browser, and create a new Dropbox app. Fill in the information of the new app as shown below, and enter the app name as generated by Dropbox Uploader.

After you have created a new app, you will see app key/secret on the next page. Make a note of them.

Enter the app key and secret in the terminal window where dropbox_uploader.sh is running. dropbox_uploader.sh will then generate an oAUTH URL (e.g., http://www2.dropbox.com/1/oauth/authorize?oauth_token=XXXXXXX).

Go to the oAUTH URL generated above on your web browser, and allow access to your Dropbox account.

This completes Dropbox Uploader configuration. To check whether Dropbox Uploader is successfully authenticated, run the following command.

$ ./dropbox_uploader.sh info
Dropbox Uploader v0.12

 > Getting info... 

Name:	Dan Nanni
UID:	XXXXXXXXXX
Email:	my@email_address
Quota:	2048 Mb
Used:	13 Mb
Free:	2034 Mb

Dropbox Uploader Examples

To list all contents in the top-level directory:

$ ./dropbox_uploader.sh list

To list all contents in a specific folder:

$ ./dropbox_uploader.sh list Documents/manuals

To upload a local file to a remote Dropbox folder:

$ ./dropbox_uploader.sh upload snort.pdf Documents/manuals

To download a remote file from Dropbox to a local file:

$ ./dropbox_uploader.sh download Documents/manuals/mysql.pdf ./mysql.pdf

To download an entire remote folder from Dropbox to a local folder:

$ ./dropbox_uploader.sh download Documents/manuals ./manuals

To create a new remote folder on Dropbox:

$ ./dropbox_uploader.sh mkdir Documents/whitepapers

To delete an entire remote folder (including all its contents) on Dropbox:

$ ./dropbox_uploader.sh delete Documents/manuals


Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

16 thoughts on “How to access Dropbox from the command line in Linux

  1. I have nothing against Dropbox but if we are serious about privacy, having your own mail and file storage servers in a place where the US authorities can't get to would be sound.

  2. I don't get it. If you're running the official DropBox client, you can open a terminal on the DropBox folder and use any file-related command (ls, rm, cp, grep, awk, find, etc...). No complex setup needed. What does this do that's not already available?

  3. @Perplexed: it may be because the dropbox client is proprietary software. Trusting the API is one thing, trusting closed source software on your machine is quite another.

  4. This is a great script, but under my company's RedHat printf's syntax seems not to work quite good :
    "encoded+=: command not found"
    or "printf: -v: invalid option"
    Do you have a clue ? I'm not that good at URL encoding in regexp-bash style...

  5. I want to use curl to talk to dropbox and found something about that on stackoverflow. Either way, it needs an oauth access token secret. How do I get that?

  6. Ok, I started all over. I created the app in dropbox, and followed all the instructions. Now I run the upload thing and upload it to "/"(plus filename).
    The reply I get is Failed: An error occurred requesting /upload

    The documentation isn't giving me any clues. Does anyone on here knows what I'm doing wrong?

    • I had the same problem, and I think it was because my token permissions didn't match what's on the dropbox account. Unlink and try again, but set permissions to "a" (App folder), not "f" (Full).

  7. That's excellent. Thank you for this great post.

    I have followed your tutorial and it work fine. However, for some reason, I was not able to upload some file types like ".tar". Any idea how to solve this.

    Thanks
    Fawaz

  8. I already had and existing dropbox app and was using it for backup of my database. I recently had to format my machine so I downloaded the script and made is executable. I ran the script and it asked for APP key and Secret Key which i supplied as the earlier App.

    So when I ran ./dropbox_uploader.sh info it gives me result, but when I ran ./dropbox_uploader.sh list it says listing failed. I cannot neither upload a file.

    Please help me. Thanks in advance.

  9. Just set this up to get screenshots and videos from my VM to Dropbox, so that I can work on a research paper. Thanks a ton Dan!

  10. For those asking "why"...

    I run a t1.micro on AWS. A dozen domains, and all the files are local. I get "ftp" and a pseudo versioning system by syncing my local sites folder to my server's folder.

    Yes, it could be done by FTP, but FTP doesn't back up files for 30 days.
    Yes, it could be done with GIT, but this is less work.

    For that purpose, I don't need privacy. It's all public webpages. It's a really good match for me.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *