We already looked at how to install and configure Dropbox in Ubuntu 18.04 desktop. Today we are going to discuss how to install Dropbox in Ubuntu 18.04 LTS server edition. Setting up Dropbox on a headless Ubuntu server that has no GUI is entirely different, but easy! And finally we will see how to install and configure Dropbox CLI client and how to use it to sync files.
Install Dropbox In Ubuntu 18.04 LTS Server
Like desktop version, Dropbox cli version is also available for both 32 and 64 bit editions.
For 32-bit:
$ cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
For 64-bit:
$ cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
This will create a new hidden folder named .dropbox-dist in your $HOME directory.
Now, run the following command to start the Dropbox daemon from the newly created .dropbox-dist folder.
$ ~/.dropbox-dist/dropboxd
You will see an output something like below.
This computer isn't linked to any Dropbox account... Please visit https://www.dropbox.com/cli_link_nonce?nonce=d6015chy89ksf023kskfc037e2 to link this device.
Next open the browser and navigate to the above link to connect system with your dropbox account. If you are on a headless server, you can use text browsers like lynx or elinks to sign-in to the dropbox account. Please note that you don't have to enter the URL in the same system itself. You can use any other system on your network that has a GUI web browser to navigate to the URL.
Once you opened the URL in the browser, you will be prompted to enter your Dropbox username and password. Just enter them and click Sign-in.
After your computer is connected to your dropbox account, you should see a message like below in your Terminal.
This computer is now linked to Dropbox. Welcome XYZ
Now, a new folder named "Dropbox" will be created in your home directory. Keep the data in this folder to access it from any devices.
$ ls Dropbox/ Apps Mackup 'Yahoo! Mail'
Congrats! The Ubuntu server has been linked to your dropbox account. The dropbox daemon will keep running until you forcibly stop it by pressing CTRL+C.
You should start it manually every time when you want to use dropbox. Of course, we can make Dropbox service to automatically start on every reboot. We are going to see how to do it in the following sections.
Install Dropbox CLI
Download the dropbox python script and put it in your PATH, for example /usr/local/bin/.
$ sudo wget -O /usr/local/bin/dropbox "https://www.dropbox.com/download?dl=packages/dropbox.py"
Make it executable:
$ sudo chmod +x /usr/local/bin/dropbox
Now you can start using the dropbox cli. To display help, simply run:
$ dropbox
To view the usage of a specific command, for example throttle, run:
$ dropbox help throttle
Now let us see if dropbox service is running or not. To do so, simply run:
$ dropbox status Dropbox isn't running!
As you see, dropbox service is not running!
To start it, run:
$ dropbox start
Let us again check if it is running using command:
$ dropbox status Up to date
It will keep running until your reboot the system.
To stop the service, run:
$ dropbox stop
To get the current sync status of a file, run:
$ dropbox filestatus Dropbox/ostechnix.txt Dropbox/ostechnix.txt: up to date
You can exclude a directory from syncing. For instance, I am going to exclude a folder named "dir1". To do so, run:
$ dropbox exclude add dir1
You can add multiple directories with space separated values like below.
$ dropbox exclude add dir1 dir2
To view the list of directories currently excluded from syncing, run:
$ dropbox exclude list
To remove a directory from the exclusion list, use this command.
$ dropbox exclude remove dir1
To get get a shared link for a file, for example ostechnix.txt, in your dropbox folder, run:
$ dropbox sharelink Dropbox/ostechnix.txt https://www.dropbox.com/s/rqteaol58c1zlkw/ostechnix.txt?dl=0
You can now pass the above URL to anyone.
To enable lansync, run:
$ dropbox lansync y
To disable it:
$ dropbox lansync n
For more commands, see the help section.
$ dropbox help
Autostart Dropbox
Like I already mentioned, you should manually start Dropbox daemon at every reboot. If you're not comfortable with manual start, follow the steps below to make it automatically start.
Create a systemd service unit for Dropbox:
$ sudo vi /etc/systemd/system/dropbox.service
Add the following lines:
[Unit] Description=Dropbox Service After=network.target [Service] ExecStart=/bin/sh -c '/usr/local/bin/dropbox start' ExecStop=/bin/sh -c '/usr/local/bin/dropbox stop' PIDFile=${HOME}/.dropbox/dropbox.pid User=sk Group=sk Type=forking Restart=on-failure RestartSec=5 StartLimitInterval=60s StartLimitBurst=3 [Install] WantedBy=multi-user.target
Replace User, Group and dropbox cli path ( /usr/local/bin/ ) with your own values. Save and quit the file.
Reload daemon using command:
$ sudo systemctl daemon-reload
Enable dropbox service:
$ sudo systemctl enable dropbox
Finally, start dropbox service with command:
$ sudo systemctl start dropbox
From now on the dropbox service will automatically start at every reboot.
To view if the service is started or not, run:
$ sudo systemctl status dropbox
Dropbox service is running and it will keep running on every reboots. You don't need to manually start it every time.
15 comments
Really helpful. Thank you.
Thank you very much for your article.
I’m trying to install dropbox to a new ubunto 18.04 on a VPS, and got stuck at the second command ~/.dropbox-dist/dropboxd with following error:
Unable to monitor entire Dropbox folder hierarchy. Please run “echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p” and restart Dropbox to fix the problem.
then,
[root@www ~]# echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p
fs.inotify.max_user_watches=100000
sysctl: permission denied on key ‘fs.inotify.max_user_watches’
sysctl: permission denied on key ‘fs.inotify.max_user_watches’
sysctl: permission denied on key ‘fs.inotify.max_user_watches’
I found somebody suggests to add this line to /etc/sysctl.conf
fs.inotify.max_user_watches=1028576
But it didn’t help me at all. What else can i do?
Never faced this error, so I am not sure if it works. Do the following and let me know if it works.
Edit sysctl.conf file:
$ sudo vi /etc/sysctl.conf
Add the following line at the end of the above file:
fs.inotify.max_user_watches = 1048576
Save and close the file.
Apply the changes:
$ sudo sysctl -p
Finally, stop and restart dropbox service:
$ sudo systemctl stop dropbox
$ sudo systemctl start dropbox
Working great on Ubuntu 16.04 – thanks
Thanks for the guide. Everything worked. However, it is using the ~/Dropbox directory on my system drive for the Dropbox folder. I want to move that to my data drive. All of the guides I find for moving this refer to the GUI version. I have seen people suggest symlinks but the Dropbox site advises against that. I just want to point Dropbox from ~/Dropbox to /mnt/data/Dropbox.
Very helpful, thank you.
Quick side note for folks that might get an error on “.dropbox-dist/dropboxd” on a fresh install of Ubuntu 18 AND installing via SSH AND your SSH lient does X forwarding by default:
$ unset DISPLAY
Thanks for your tip, Nick. Hope someone find it useful.
Thanks! Really useful.
This is great and I enjoyed the easy-to-follow instructions, but am lost in understanding what determines what get’s uploaded to Dropbox?
Is there a way to create a cronjob to perform a backup of small amounts of data at regular intervals?
On my computer I have Ubuntu 18.04 LTS Server. On this computer is Nextcloud installed.
I want to sync 3 Dropbox accounts – in separate folders.
Therefore I connect account #1, using the connecting link in an incognito window, syncing all files and folders onto the Nextcloud folder of account #1
and the same operation for accounts #2 and #3.
Because I do not waste time, I am looking for an option to do that using a script.
Can you help me writing such a script?
Hi,
I have very limited knowledge in programing. I couldn’t help you. My apologies. Please post your question in this forum. Someone might help.
https://www.reddit.com/r/scripting/
Referring to my question above: is there an option to set the directory Dropbox is downloading the files onto?
At this moment the files are downloaded to /root/Dropbox. I think my question can be solved if I can define the destination directory of the downloaded files.
Yes, it is possible. Have a look at this thread. The first solution seems to fit your requirement.
It seems the given instructions at this website doesn’t work with the most recent release of Ubuntu (20.04 – today I used the beta release).
This guide is not yet tested with Ubuntu 20.04. We will do it after Ubuntu 20.04 released.