This post will help you install the Linux Dropbox client on your headless Ubuntu Server and link it up to your Dropbox account. The Dropbox approach is a great 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!
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.
To download the 32Bit Version
wget -O dropbox.tar.gz "http://www.dropbox.com/download/?plat=lnx.x86"
To 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
It will start outputting a link similar to this one every few seconds
This client is not linked to any account...
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
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
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
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
Control the Dropbox client like any other Ubuntu service
sudo service dropbox start|stop|reload|force-reload|restart|status
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"
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
Get a full list of CLI commands
Note: use dropbox help
|status||get current status of the dropboxd|
|puburl||get public url of a file in your dropbox|
|running||return whether dropbox is running|
|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
“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 Text Based Linux Install page on the Dropbox wiki and the Dropbox forums. Happy syncing!