Home Dropbox How To Install Dropbox In Ubuntu 18.04 LTS Server

How To Install Dropbox In Ubuntu 18.04 LTS Server

By sk
Published: Last Updated on 3.6K views

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.

Dropbox is linked to your computer
Dropbox is linked to your computer

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
Dropbox CLI
Dropbox CLI

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
Check dropbox service status
Check dropbox service status

Dropbox service is running and it will keep running on every reboots. You don't need to manually start it every time.

You May Also Like

15 comments

Reg Natarajan May 26, 2018 - 12:45 am

Really helpful. Thank you.

Reply
Ming Liu October 12, 2018 - 7:24 am

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?

Reply
sk October 12, 2018 - 10:16 am

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

Reply
xy2z October 26, 2018 - 12:18 am

Working great on Ubuntu 16.04 – thanks

Reply
Tom December 3, 2018 - 9:11 pm

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.

Reply
Nick G December 21, 2018 - 12:43 am

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

Reply
sk December 21, 2018 - 12:02 pm

Thanks for your tip, Nick. Hope someone find it useful.

Reply
Riccardo Mannella January 4, 2019 - 5:55 pm

Thanks! Really useful.

Reply
Justin Russell November 5, 2019 - 6:00 am

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?

Reply
Guido van Harten January 7, 2020 - 10:10 pm

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?

Reply
sk January 7, 2020 - 11:05 pm

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/

Reply
Guido van Harten January 9, 2020 - 6:19 pm

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.

Reply
sk January 10, 2020 - 1:54 pm

Yes, it is possible. Have a look at this thread. The first solution seems to fit your requirement.

Reply
Guido van Harten April 17, 2020 - 8:38 pm

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

Reply
sk April 17, 2020 - 9:06 pm

This guide is not yet tested with Ubuntu 20.04. We will do it after Ubuntu 20.04 released.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More