Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Post

Install Dropbox On Ubuntu Server (10 & 11)

Dropbox FUSION Icon By Parthiban Mohanraj
Dropbox FUSION Icon By Parthiban Mohanraj

This post will help you install the Linux Dropbox client on your headless Ubuntu Server and link it up to your Dropbox account. Unlike the process of mounting an S3 bucket we looked at before the Dropbox approach is a much better solution for sharing files. If you’re a daily Dropbox user you’ll quickly get hooked on the convenience of having your servers in the same file sharing loop as all your other Dropbox connected devices!

Installing Dropbox

Start off by downloading the Linux version of Dropbox onto your server. These steps have been tested on Ubuntu Server 10.10 and 11.04.

Download the 32Bit Version

wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"

Download the 64Bit Version

wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86_64"

If you unsure which version you need you can quickly check by running uname -a.

sudo uname -a

If the uname output has an i686 at the end you need the 32Bit version and if it has x86_64 you want the 64Bit version.

When you extract the Dropbox archive it will automatically place its files in the home directory of the the user you’re logged in as under: ~/.dropbox. You can always move these files later but its something to keep in mind.

Extract the Dropbox archive

tar -xzvf dropbox.tar.gz

Linking Your Server to Your Dropbox Account

Before you take the next step you’ll want to make sure your LANG environment variable is set to a value other than NULL.

Check the value of your LANG environment variable

printenv LANG     // outputs en_US.UTF-8 on my machine

To connect the Dropbox client on your server to your Dropbox account you’ll need to copy the link it outputs into a browser window and then login to your Dropbox account.

Run dropboxd on your server

~/.dropbox-dist/dropboxd

It will start outputting a link similar to this one every few seconds

This client is not linked to any account...
Please visit https://www.dropbox.com/cli_link?host_id=1c1497d78b543178b9349a7c1a8b087a&cl=en_US to link this machine.

The trick to a smooth link is to make sure you leave dropboxd running while you follow the link. You don’t need to access the link from the server you’re trying to install Dropbox on. You can copy and paste that link into a browser running on a separate machine and Dropbox will authorize the client running on your server.

Once it succeeds you’ll see the message Client successfully linked, Welcome! on your server and it will stop printing the authorization link.

Hit ctrl c to terminate the process

Client successfully linked, Welcome!

Once the Dropbox client on your server is successfully linked it will automatically create a Dropbox folder under ~/Dropbox for the user you’re logged in as. All your folders will be visible under the Dropbox folder but since the Dropbox service isn’t actually running on your server yet you you won’t be able to see the files inside these folders until the client is running and has a check to synchronize.

You can manually start the service by running

~/.dropbox-dist/dropbox

However, a better option for controlling the Dropbox client is to setup an Ubuntu service management script for it.

Start Dropbox Automatically On Boot

Dropbox provides a handy little service management script that makes it easy to start, stop and check the status of the Dropbox client.

Create a new file for the service management script

sudo vi /etc/init.d/dropbox

Paste the following script into the new file

#!/bin/sh
# dropbox service
# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="user1 user2"
 
DAEMON=.dropbox-dist/dropbox
 
start() {
    echo "Starting dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}
 
stop() {
    echo "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}
 
status() {
    for dbuser in $DROPBOX_USERS; do
        dbpid=`pgrep -u $dbuser dropbox`
        if [ -z $dbpid ] ; then
            echo "dropboxd for USER $dbuser: not running."
        else
            echo "dropboxd for USER $dbuser: running (pid $dbpid)"
        fi
    done
}
 
case "$1" in
 
    start)
        start
        ;;
 
    stop)
        stop
        ;;
 
    restart|reload|force-reload)
        stop
        start
        ;;
 
    status)
        status
        ;;
 
    *)
        echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
        exit 1
 
esac
 
exit 0

Make sure you replace the value of DROPBOX_USERS with a comma separated list of the linux users on your machine you want to run the Dropbox client to run for. Each user in the list should have a copy of the Dropbox files and folders that you extracted from the archive, available under their home directory.

Make sure the script is executable and add it to default system startup run levels

sudo chmod +x /etc/init.d/dropbox
sudo update-rc.d dropbox defaults

Control the Dropbox client like any other Ubuntu service

sudo service dropbox start|stop|reload|force-reload|restart|status

Dropbox Delorean By Dropbox Artwork Team
Dropbox Delorean By Dropbox Artwork Team

Depending upon the number of files you have on Dropbox and the speed of your internet connection it may take some time for the Dropbox client to synchronize everything.

Check Status with Dropbox CLI

Dropbox has a command line python script available separately to provide more functionality and details on the status of the Dropbox client.

Download the dropbox.py script and adjust the file permissions

wget -O ~/.dropbox/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"
chmod 755 ~/.dropbox/dropbox.py

You can download the script anywhere you like, I’ve included it along with the rest of the Dropbox files.

Now you can easily check the status of the Dropbox client

~/.dropbox/dropbox.py status
Downloading 125 files (303.9 KB/sec, 1 hr left)

Get a full list of CLI commands

~/.dropbox/dropbox.py help
 
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

Use the exclude command to keep specific files or folders from syncing to your server

~/.dropbox/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.

Once the Dropbox service is running and fully syncrhonized you can access all your Dropbox files and easily share files on your server with all your other Dropbox connected gadgets!

For more resources and troubleshooting tips visit the Dropbox forums. Happy syncing!

  • Prashant Raju

    Great post! Finally a guide that just works!

    Keep up the good work.

  • http://rawberg.com/blog David Feinberg

    Thanks for the kind words Prashant, glad to hear you got everything working!

  • http://putokaz.wordpress.com/2011/06/05/installing-dropbox-on-ubuntu-server/ Installing dropbox on Ubuntu server « Putokaz
  • Anonymous

    What a great guide — very clear and, as Prashant said, it just works! Thanks and I look forward to your service launching.

  • http://rawberg.com/blog David Feinberg

    thanks for the positive feedback djmccormick!

  • Jonas Nyström

    Great! Thanks! Using the Dropbox GUI, it’s possible to controll specifically what folders to be synced. Can this somehow be done from the command-line too?

  • http://rawberg.com/blog David Feinberg

    You got it, you just have to use the exclude command.
    http://wiki.dropbox.com/TipsAndTricks/UsingDropboxCLI#EXCLUDE

  • Kyle

    For some reason, the nice format of this guide makes this look much friendlier. lol!

  • Darksteel Shaman

    Incredible guide! Got dropbox up and running in no time! Thanks a bunch :)

  • http://rawberg.com/blog David Feinberg

    Glad to hear it worked out for you Darksteel and thanks for the positive feedback!

  • http://adminsgoodies.com/dropbox-on-linux-server-how-to-includeexclude-folders/ Dropbox on linux server – how to include/exclude folders? – Admins Goodies

    [...] Background: I’m trying out the solutions for installing Dropbox on a linux server given here, and it seems to work fine: http://ubuntuservergui.com/ubuntu-server-guide/install-dropbox-ubuntu-server [...]

  • Daniel

    Thank you for this post, very helpful :)

  • Adamjseed

    David, Great tutorial.

    Do you know how to move the drobox folder to a different location on a headless install?

    Im thinking that I may need to install the full client and forward the x11 to move it.

  • http://rawberg.com/blog David Feinberg

    Have you tried manually changing the PARENT_DIR setting in the dropbox.py file?

  • http://rawberg.com/blog David Feinberg

    Glad to hear it helped you out!

  • Sebastian Sawicki

    Haven’t you hear about upstart? Using /etc/init.d is deprecated ;]
    What’s more if you have root access it would be nice to place dropbox-dist files (which are mainly binaries and some libs) in some system folder. I’ve putted it in /opt/dropbox-dist :
    # sudo mv ~/.dropbox-dist /opt/dropbox-dist
    # sudo chown -R root:root /opt/dropbox-dist
    # sudo chmod -R go-w /opt/dropbox-dist

    …there is no need in having same binaries for each user.

  • http://rawberg.com/blog David Feinberg

    Good tips Sebastian, thanks for sharing!

  • http://roguishcode.com/2012/01/using-dropbox-for-web-development-anywhere/ Using Dropbox for Web Development Anywhere – roguishcode | roguishcode

    [...] are many guides out there, but here is one I recommend (and used myself). Install Dropbox On Ubuntu Server (10 & 11) I like to exclude the syncing of any folder(s) I don’t want to be available for Apache to [...]

  • Toeu

    awful ubuntu guide =) thanx a 1000 times for describing in detail ! TöU

  • http://www.penghou.net/blog/2010/11/18/install-dropbox-on-server/ Install Dropbox on Server(New) | 侯三儿

    [...] Install Dropbox on your Server 32Bit Version wget -O dropbox.tar.gz “http://www.dropbox.com/download/?plat=lnx.x86&#8243; 64Bit Version wget -O dropbox.tar.gz “http://www.dropbox.com/download/?plat=lnx.x86_64&#8243; 下载CLI.解压后在当前用户家目录下得到~/.dropbox-dist/目录. 执行~/.dropbox-dist/dropboxd 得到信息说还没有link to account,去给出的网址登录一下,link成功 [...]

  • http://www.freeminded.org/ Skidder

    If you copy-paste from some browsers you’ll get a lot of TAB characters. Fix this in vi/vim with

    %s/t//g

    It replaces all TAB characters (t) with nothing.

  • http://roguishcode.com/?p=79 Web Development Anywhere Using Dropbox – roguishcode | roguishcode

    [...] are many guides out there, but here is one I recommend (and used myself). Install Dropbox On Ubuntu Server (10 & 11) I like to exclude the syncing of any folder(s) I don’t want to be available for Apache to [...]

  • Jorgen

    Great work! Thanks a lot!!!

  • eagle

    Thank you so much. This is the first linux tutorial I have not had to rewrite for my own understanding and as such deserves praise. Congratulations on making by far the best Dropbox CLI tutorial and the best Linux CLI tutorial I have read.

  • http://rawberg.com/blog David Feinberg

    Thanks eagle, I’ve been meaning to blog more but I’ve been consumed with coding. Comments like these get me motivated again. Any suggestions on other topics?

  • http://www.squareoneinsurance.ca/ Jason Vanderzalm

    Instructions worked perfectly – made me feel like a ubantu expert!

  • http://www.facebook.com/ivan.karpan Ivan Karpan

    BTW you can connect to the server via
    ssh -X
    And this way you will be able to do the set up with a GUI. And set up selective syncing.

  • http://linuxaria.com/article/install-dropbox-on-ubuntu-server-10-11?lang=en » Linuxaria – Everything about GNU/Linux and Open source Install Dropbox On Ubuntu Server (10 & 11)

    [...] After the last article of Dropbox I thought it was useful to show how you can use Dropbox also on a server without a GUI, this useful article by David Feinberg was published on http://ubuntuservergui.com/ [...]

  • Erik013

    to download it I need to add “–no-check-certificate” option as follow
    wget -O dropbox.tar.gz “http://www.dropbox.com/download/?plat=lnx.x86″ –no-check-certificate

  • http://rawberg.com/blog David Feinberg

    thanks for sharing that tip!

  • Sierraalphaindia

    Fantastic guide – thanks! This is now synchronizing my code on multiple servers…

  • the lonewolf

    works like a dream! just one query tho, will the fownload to the dropbox actually continue even tho the user has logged out of the server? (before anyone says it yes thats a DURRR! question but i just wondered! and im a near novice on ubuntu server!)

  • http://rawberg.com/blog David Feinberg

    glad you got everything setup lonewolf! syncing will continue even when you logout of the server.

  • http://ominian.com/2012/04/05/selective-sync-for-ubuntu/ Selective Dropbox sync for Ubuntu » Refactored scope

    [...] a good tutorial to setup the CLI Dropbox agent – This one is the most concise [...]

  • http://norwied.wordpress.com/2012/04/11/install-dropbox-on-a-headless-ubuntu-10-04-lts-server/ install Dropbox on a headless Ubuntu 10.04 LTS server « my tiny TechBlog
  • Anonymous

    Awesome! Thanks!

  • http://twitter.com/maxxer maxxer

    the user list is space separated, not comma

  • Seth Davis

    Wow, phenomenal guide! Every how-to on the internet needs to follow this format! With a guide like this, I don’t want to constantly set my linux server on fire.

  • http://rawberg.com/blog David Feinberg

    Glad it worked out for you Seth! Now put down the torch and step away from the linux server :)

  • http://www.planetahuevo.es/ darkpollo

    Great guide. Thanks! Do you know how to make the same with SpiderOak?

  • http://rawberg.com/blog David Feinberg

    Thanks for the feedback! I haven’t played with SpiderOak but I’ll definitely check it out.

  • Stephen

    Many thanks for this, is there any reason why this wouldn’t work in Ubuntu 12?

  • potes

    thanks for the guide. Its work great in ubuntu server 12.04

  • http://twitter.com/jsnmcknz Jason McKenzie

    So very helpful. Thank you!

  • Stanko Trček

    What else to say, thank you.

  • clumsybell

    Great walkthrough, really concise, clear, and informative. Thanks!

  • http://www.facebook.com/jefffan24 Adam Heim

    Seriously thank you for this guide, have made moving files between my ubuntu VM and my win7 computer much easier!

  • http://twitter.com/kermit666 Dražen Lučanin

    A handy one-liner to exclude everything from syncing

    ~/.dropbox/dropbox.py exclude add `for f in ~/Dropbox/*; do echo -n $f” “; done`

    After this you can enable some specific folder using

    ~/.dropbox/dropbox.py exclude remove ~/Dropbox/wanted-folder

  • http://rawberg.com/blog David Feinberg

    Awesome tips! Thanks for sharing.

  • http://www.facebook.com/nagyp Péter Nagy

    thanks for the great tutorial!

  • Paul Seyler

    Is it possible to configure Dropbox to start immediately upon boot, even if no user is logged in? Possibly as a root service, rather than linked to one or more individual user accounts?

    Thanks for the great tutorial so far!

  • Anonymous

    Quality guide – thanks!