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(8) Unhelpful(1)
  • 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?

    • http://www.itersdesktop.com/ Nguyen Vu Ngoc Tung

      Hi François,
      Unfortunately, I forgot to synchronize dropbox before leaving the office. When I come to my house, I’ve done the thing as you want to know. There is a simple way (I guess you want to remote you Linux server) using ssh/terminal:
      – Stop dropbox by the command: dropbox stop
      – Then start dropbox: dropbox start. Your files will be synchronized automatically.

  • 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.

    • Andreas

      When starting the dropboxd, make sure none of the ENV vars are set to de_DE…don’t know which ones exactly make the difference.

  • 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…

    • Qing

      Yeah, that’s exactly what i need also, it’s really annoying to add new folders into the excluding list when I created new folders in other machine…

      • Fab Milky

        +1

      • http://www.simenschi.com Simen Schikulski

        +1

      • John Randall

        +1

  • 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()

  • Stefan

    Is it possible to change the location of the Dropbox directory?
    My /home dir is very small and it is not supposed to contain huge data like this.

  • Pingback: Axross.org – さくらVPSを契約してCentOS6.4をNode.js Webアプリケーションサーバーとして構築するチュートリアル()

  • Ethan Setnik

    It would be great if you could exclude by wildcard.

  • http://devel.androidsith.com Hpsaturn

    Please implements dropbox shortener url for puburl, thanks!

  • Mau Lazyhola

    This script is very neat. It would be totally awesome if I could exclude with wildcards.

    In my particular case I sync database backups for each of my client’s. It would be lot easier to say something like “stop sync everything except ” instead of the current way it works.

    Anyway the tool is very powerful. I will upgrade my account pretty soon. Thanks.

  • OSSAlanR

    I get “Couldn’t get public url: Unknown Error” when I give it the name of a folder under a public folder. However, I *can* successfully produce a public URL for this same directory using the web.

    How do I get this same behavior from the dropbox.py command line tool?

  • http://341design.com.au Chris Howard

    Is the exclude list saved in a config file somewhere that I can just edit directly?

  • George Papadopoulos

    How can I download the CLI via the command line using curl instead of wget (I’m really new to command line operation so I’m clueless)?

  • Mark Grundy

    The one thing I would really like from command line is to be able to find out the space used/free in the dropbox.

  • DaylateDollarshort

    mkdir -p ~/bin
    curl -O https://linux.dropbox.com/packages/dropbox.py
    chmod +x ~/bin/dropbox.py

  • Select Field

    hey this is great you should put a link to this wiki on the install page: https://www.dropbox.com/install?os=lnx for linux

  • Chris

    It would be great to get a way to change the folder… right now it’s kinda shitty.

  • Pingback: Ubuntu as a home server. Part 5. Reliability.()