This article assumes you have already installed Dropbox as per the instructions here.

Installation

Download the Dropbox command line interface or get it via the command line: First make a bin directory, or a directory of your choosing. The examples below all assume you made a bin directory:

mkdir -p ~/bin

Download the CLI interface via  wget:

wget -O ~/bin/dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py"

Set the permissions so you can execute the CLI interface:

chmod +x ~/bin/dropbox.py

Getting Started

Start off by printing the help menu:

~/bin/dropbox.py help

which will show you all the commands you can use

status       get current status of the dropboxd
help         provide help
puburl       get public url of a file in your dropbox
stop         stop dropboxd
running      return whether dropbox is running
start        start dropboxd
filestatus   get current sync status of one or more files
ls           list directory contents with current sync status
autostart    automatically start dropbox at login
exclude      ignores/excludes a directory from syncing

As the help menu shows, to start Dropbox, simply type

~/bin/dropbox.py start

If successful, it should show

Starting Dropbox...Done!

Then check its status with

~/bin/dropbox.py status

Commands

STATUS

Description

get current status of the dropboxd

Usage

Basic usage   dropbox.py status Example         ~/bin/dropbox.py status Combined with “watch” command watch ‘~/bin/dropbox.py status’

Sample output

$ ~/bin/dropbox.py status
Indexing 317 files...
$ ~/bin/dropbox.py status
Idle

HELP

Description

provide help

Usage

Basic usage    dropbox.py help Example          ~/bin/dropbox.py help Command help usage  dropbox.py help COMMAND Example          ~/bin/dropbox.py help exclude

Sample output

$ ~/bin/dropbox.py help
Dropbox command-line interface
commands:

Note: use dropbox help <command> to view usage for a specific command.

status       get current status of the dropboxd
help         provide help
puburl       get public url of a file in your dropbox
stop         stop dropboxd
running      return whether dropbox is running
start        start dropboxd
filestatus   get current sync status of one or more files
ls           list directory contents with current sync status
autostart    automatically start dropbox at login
exclude      ignores/excludes a directory from syncing
$ ~/bin/dropbox.py help puburl
dropbox puburl FILE
Prints out a public url for FILE.

PUBURL

Description

get public url of a file in your dropbox

Usage

Basic usage    dropbox.py puburl FILE Example          ~/bin/dropbox.py puburl ~/Dropbox/Public/file.zip

Sample output

$ ~/bin/dropbox.py puburl ~/Dropbox/Public/file.zip

http://dl.dropbox.com/u/XXXXXXX/file.zip

If not used on a file in your Public folder, you will get an error message:

$ ~/bin/dropbox.py puburl ~/Dropbox/myFolder/file.zip 
Couldn't get public url: Unknown Error

STOP

Description

stop dropboxd

Usage

Basic usage    dropbox.py stop Example          ~/bin/dropbox.py stop

Sample output

$ ~/bin/dropbox.py stop
Dropbox daemon stopped.

RUNNING

Description

return whether dropbox is running

Used in scripts to check if Dropbox is running. This command does not output anything to the user.

Extra Info

$ ~/bin/dropbox.py help running
dropbox running
Returns 1 if running 0 if not running.

Usage

Basic usage    dropbox.py running Example          ~/bin/dropbox.py running

Sample output

$ ~/bin/dropbox.py running
<no output>

EXCLUDE

Description

ignores/excludes a directory from syncing

Used in scripts to check if Dropbox is running. This command does not output anything to the user.

Extra Info

$ ~/bin/dropbox.py help exclude
dropbox exclude [list]
dropbox exclude add [DIRECTORY] [DIRECTORY] ...
dropbox exclude remove [DIRECTORY] [DIRECTORY] ...
"list" prints a list of directories currently excluded from syncing.  
"add" adds one or more directories to the exclusion list, then resynchronizes Dropbox. 
"remove" removes one or more directories from the exclusion list, then resynchronizes Dropbox.
With no arguments, executes "list". 
Any specified path must be within Dropbox.

Usage

List usage:    dropbox.py exclude list Example        ~/bin/dropbox.py exclude Example        ~/bin/dropbox.py exclude list Add exclusion usage  dropbox.py exclude add DIRECTORY Example        ~/bin/dropbox.py exclude add ~/Dropbox/MyExcludedFolder Remove exclusion usage   dropbox.py exclude remove DIRECTORY Example       ~/bin/dropbox.py exclude remove ~/Dropbox/MyReincludedFolder

Sample output

$ ~/bin/dropbox.py exclude list
Excluded: 
Dropbox/backup
Dropbox/documents
Dropbox/music
Dropbox/papers
Dropbox/photos
Dropbox/pictures
$ ~/bin/dropbox.py exclude add ~/Dropbox/MyExclude1 ~/Dropbox/MyExclude2 ~/Dropbox/MyExclude3
[...]

Share the Knowledge!

Helpful(3) Unhelpful(0)
  • Pingback: Project: Aquarium Server - mrpc’s Blog

  • Pingback: Cloud Storage Services on Linux Platforms | LinuxNov

  • Francois

    Is there a way to pause/unpause the synchronization from the command line?

    • un person

      Is there a way to start Dropbox in pause-sync mode, from the command line?

  • Hardus

    I just want to add that I had trouble running the dropbox.py, I had it executable and all the tutorials show for example: dropbox.py help, that don’t work like that, you have to run it as a executable like: ./dropbox.py help then only it works.

  • Michael

    I got the following error during synchronization of files that cannot be accessed because the message Dropbox throws contains characters that cannot be read by the script.

    UnicodeEncodeError: ‘latin-1′ codec can’t encode character u’u201e’ in position 10: ordinal not in range(256)

    Anybody knows what I can do to solve this?

    I’m using Debian 7.0 (Wheezy) 64bit with an installed Dropbox client fetched by the linked script from this guide.

    Since the mentioned character is the DOUBLE LOW-9 QUOTATION MARK („) it appears that it comes from one of the German messages Dropbox sends to the client. Maybe it is just a configuration of the client itself, I don’t know this.

    I’d change the language of the client to English if someone tells me how. But fixing the error would be nice.

  • Stanislav

    Very useful cli program. In my opinion it lacks such a feature as a callback. For example, when after Dropbox starts and finishes the synchronization

  • Pingback: Guidelines to setup a perfect Digital Ocean VPS | NARGA

  • Harringer

    Is there any relationship between the dropboxd (dropox daemon) and the usual dropbox client? I thought I could use the dropbox CLI to track the activity of the dropbox client, but it seems that both apps are independent.

  • Pingback: How To Install & Configure Headless Dropbox as a Service on Ubuntu 12.04 | vDevices

  • tcumming

    If someone shares their dropbox with me by sending me a url, how can I reference it with a cli? What if it’s a shared directory? What if I want to modify a file in a directory they’ve shared with me?

  • Achim

    I am glad I discovered this command line utility — very helpful. However, I was hoping for a command that would list the recent synchronisation events (much like the “events” page that I get when I log into the online Dropbox account).

  • Chad

    Dropbox… almost all your stuff works great, with the exception of this daemon and command line utility….

    How about something to pause the syncing, and something to exclude all the folders in my dropbox while letting me pick only what I do want to download…

  • RobbieD

    How do you exclude folders that include spaces? I have tried:

    ~/.dropbox/dropbox.py exclude add “~/Dropbox/Camera Uploads”

    … but that doesn’t work.

    • RobbieD

      Sorry – my bad… This worked:

      ~/.dropbox/dropbox.py exclude add ~/Dropbox/Camera Uploads

  • Pingback: Webserver Dropbox Sync | Kingston IT

  • Luis Navarro

    How can I link with an accoun by this way?. Thanks

  • Pingback: Synchronizing Dropbox files with Hubic