Tutorial

How To Install Dropbox Client as a Service on Ubuntu 14.04

Published on February 25, 2016
How To Install Dropbox Client as a Service on Ubuntu 14.04

Introduction

In this tutorial, we’ll show you how to install the Dropbox client, and configure it to run as a headless service, on an Ubuntu 14.04 server. This will allow your server to connect to Dropbox so that you can keep a copy of your Dropbox files synchronized on your server.

Prerequisites

You must have a non-root user with superuser privileges (sudo). To set that up, follow at least steps 1 through 3 in the Initial Server Setup with Ubuntu 14.04 tutorial. All of the commands in this tutorial will be executed as this non-root user.

Once you’re ready, we’ll install the Dropbox client.

Install Dropbox Client

The latest version of the Linux Dropbox client can be downloaded to your home directory with these commands:

  1. cd ~
  2. curl -Lo dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64

Now you will have a file called dropbox-linux-x86_64.tar.gz in your home directory.

Note: If you’re running a 32-bit distribution, use this command to download the 32-bit Linux client instead:

cd ~
curl -Lo dropbox-linux-x86.tar.gz https://www.dropbox.com/download?plat=lnx.x86

Next, extract the contents of the Dropbox archive to /opt/dropbox with these commands:

sudo mkdir -p /opt/dropbox
sudo tar xzfv dropbox-linux-x86_64.tar.gz --strip 1 -C /opt/dropbox

The Dropbox client is now on your server, but you need to link it with your Dropbox account.

To link your Dropbox client with your Dropbox account, run this command (as the user whose home directory you want to store the Dropbox files in):

  1. /opt/dropbox/dropboxd

This starts the Dropbox client in the foreground, so you won’t be able to enter any other commands at the moment. The first time you run the client, you should see output that looks like this:

Host ID Link:
This computer isn't linked to any Dropbox account... Please visit https://www.dropbox.com/cli_link_nonce?nonce=ac8d12e1f599137703d88f2949c265eb to link this device.

Visit the URL in the output (highlighted in the above example) in a web browser on your local computer.

Log in to Dropbox (if you aren’t already logged in), then click the connect button:

Dropbox Connect Prompt

After seeing a success message in your web browser, you should see this output on your Ubuntu server:

Link success output:
This computer is now linked to Dropbox. Welcome Sammy

Now your Dropbox account is linked with the client. You should now have a directory in your home directory called “Dropbox”. This is where it will store your synchronized Dropbox files.

Press Ctrl-C to quit running Dropbox for now.

The next step is to set up some scripts so that Dropbox will run as a service, so that you don’t need to be logged in for the client to keep running.

Set Up Service Script

To start Dropbox as a service, you’ll need create a script. To save yourself the trouble, you can use this command to download one to /etc/init.d/dropbox:

  1. cd ~
  2. sudo curl -o /etc/init.d/dropbox https://gist.githubusercontent.com/thisismitch/d0133d91452585ae2adc/raw/699e7909bdae922201b8069fde3011bbf2062048/dropbox

Next, make the script executable with this command:

sudo chmod +x /etc/init.d/dropbox

The script expects the /etc/default/dropbox file to contain a list of system users that will run Dropbox. Create the file and open it for editing with this command:

  1. sudo nano /etc/default/dropbox

Add a line that specifies that DROPBOX_USERS is equal to your system username. For example, if your username is “sammy”, it should look like this:

/etc/default/dropbox
DROPBOX_USERS="sammy"

Save and exit the file by pressing Ctrl-x, then y, then Enter.

Now Dropbox is ready to be started as a service. Run this command to start it:

  1. sudo service dropbox start

Then run this command to configure the service to start when your server boots:

  1. sudo update-rc.d dropbox defaults

Now the Dropbox client is running as a service and will start automatically when your server boots.

Install Dropbox CLI

Dropbox also includes a command line interface (CLI) that you may want to install so that you can configure your Dropbox client.

To download it to your home directory, run these commands:

cd ~
curl -LO https://www.dropbox.com/download?dl=packages/dropbox.py

Now you will have a file called dropbox.py, the Dropbox CLI, in your home directory.

Use this command to make it executable:

chmod +x ~/dropbox.py

Then, in your home directory, make a symbolic link named .dropbox-dist that points to your Dropbox installation path. This is necessary because the Dropbox CLI expects ~/.dropbox-dist to contain your Dropbox installation:

  1. ln -s /opt/dropbox ~/.dropbox-dist

Now you can run the Dropbox CLI from your home directory with this command:

  1. ~/dropbox.py

This will print out a basic help page. The next subsection will cover how use the Dropbox CLI to do a few basic things.

How to Use the Dropbox CLI

Remember that running the CLI without any options with print out how to use it.

If you want to check the status of your Dropbox, use the status command:

  1. ~/dropbox.py status

If all of your files are synchronized, you should see this message:

Output:
Up to date

You can also use it to turn off the automatic LAN sync feature, which tries to synchronize relevant files on your LAN:

  1. ~/dropbox.py lansync n

Another handy command is exclude. This will let you specify files and directories that should not be synchronized on your server. For example, if you don’t want your server to download the photos directory from Dropbox, you could run this command:

  1. ~/dropbox.py exclude add ~/Dropbox/photos

Then you can verify which files and directories are excluded from your server with this command:

  1. ~/dropbox.py exclude list

Feel free to play with the CLI to see what else you can do with it.

If you want to link more Dropbox accounts, follow this section.

It is possible to link multiple Dropbox accounts to your server. However, you will require an additional system user for each Dropbox account that you want to link. If you don’t know how to add users to your Ubuntu server, follow this tutorial: How To Add and Delete Users on Ubuntu.

Once you have the system user account that you want to use, log in to your server as that user.

Run /opt/dropbox/dropboxd. As before, this will output a URL to link a Dropbox account to with server.

Log in to Dropbox under the account that you want to link to your server. Then visit the URL on your server, and click the connect button.

Next, edit /etc/default/dropbox:

  1. sudo nano /etc/default/dropbox

Add the new system user to the list of Dropbox users. For example, if you have two system users running Dropbox, “sammy” and “ben”, it would look something like this.

/etc/default/dropbox
DROPBOX_USERS="sammy ben"

Save and exit the file by pressing Ctrl-x, then y, then Enter.

Now restart the Dropbox service:

  1. sudo service dropbox restart

Now your server is linked to multiple Dropbox accounts.

To use the CLI on the new user, be sure to follow the Install Dropbox CLI section again as the new user.

If you want to unlink a Dropbox account, follow these steps.

First, stop the service:

  1. sudo service dropbox stop

Then edit /etc/defaults/dropbox and remove the user from the list.

Then delete the user’s Dropbox directory. For example:

  1. sudo rm -r ~/ben/Dropbox

Then, if your server still has other Dropbox accounts linked to it, start the Dropbox client again:

  1. sudo service dropbox start

Lastly, if you want to restrict access completely, you can go to your Dropbox Account Security page and delete any linked devices.

Conclusion

The Dropbox client is now installed and running on your server. Your server should now be linked and synchronized with your Dropbox account.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hello, thanks for the post…

i’m facing some troubles during the process…

for example, when I execute

sudo service dropbox start

the answer is the following

Failed to start dropbox.service: Unit dropbox.service not found.

but all the previous commands were executed without errors or warnings… any suggestion on how to solve it?

Thanks is advance…

I followed these steps on a freshly spun up server… and it works for about 30 seconds, then the service stops. When I run

~/dropbox.py status

I get the status

Dropbox isn't running!

I can restart, have it run for a less than a minute then it dies again. Any ideas? Only a few files sync each time.

oh my goodness… i nearly gave up on linking my server!!! yikes…

i first wasn’t able to select, let alone copy, text on the web console another problem. Then, my iOS ssh app (Termius) would disconnect after switching away from the app for a few seconds. Then, Dropbox would tell me i have too many devices, or log me out. Wow, this reminds me of pre-Windows 95 days… my god, what a nightmare! :(

i can’t seem to get the server to connect to Dropbox. I added the server to Dropbox’s device list. I even have two entries of the same device!? Maybe the server does some networking magic, changing it’s IP address or something, throwing Dropbox off?

Followed each step and worked perfectly… but two months later and something has stopped working - the server claims it is up to date, but the dropbox account has a growing list of files in it - it isn’t syncing. What can I try to get it running again?

This breaks every time Dropbox issues an update. Isn’t there a better way to install Dropbox, like maybe with nautilus?

I have installed dropbox and everything worked great. But I suddenly noticed that dropbox is not syncing any more. Then I went to command line and put the command ~/dropbox.py status to see the status, and I saw this:

You're using an old version of Dropbox. Please update to the latest version to continue using Dropbox.

https://www.dropbox.com/downloading?from_client=True

So what I understand from it that when there was an update in dropbox, the service on my ubuntu stopped working.

Now I updated with these commands and its working fine now:

curl -Lo dropbox-linux-x86_64.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64
sudo tar xzfv dropbox-linux-x86_64.tar.gz --strip 1 -C /opt/dropbox
~/dropbox.py stop
~/dropbox.py start

Now, the problem is that I don’t know when the dropbox is going to release an update and so my dropbox will stop. So there definitely should be a way to auto update dropbox and keep the system up and running all the time.

How can I setup that auto update?

I think there’s a problem with the downloaded script. The service won’t start for me using the instructions above (sudo service dropbox start). I have no trouble starting the service using Dropbox’s recommended method (~/.dropbox-dist/dropboxd).

Of course this runs it in the foreground, and we want to run it as a service on bootup. I’m going to dig into how to get this up and running, and maybe fiddle with the downloaded script here to see if I can get it to work.

Would love to see an update by the OP, as he surely knows more about this stuff than I do.

Once again great tutorial, everything is working just fine, except that since I started using dropbox on my ec2 ubuntu, whenever dropbox is syncing, CPU uses shows 100%, I see this with glances. When I use the command “top”, it shows that dropbox is using more than 90% cpu. As soon as I stop dropbox, the cpu uses is less than 5%.

Then I used google to see what can cause this, and found this article: https://www.dropbox.com/en/help/9199

Based on the above article, there maybe a permission issue, but I don’t know how to fix that on my ubuntu machine. I’m using t2 small ec2, so not sure if I need to upgrade to a high power ec2, but I think if even I upgrade it to double or triple, the problem will persist.

Any idea how I can fix this issue?

Best regards

Thanks for the tutorial. I’m trying to figure out how to unlink an old dropbox. I’ve tried removing ~/user/Dropbox however now I get This computer was previously linked to XXXX's account I presume there’s something hiding in ~/user/.dropbox/

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.