Linux – How to get the URL of Dropbox file from command line

bashcommand linedropboxlinux

I would like to know if I can get the URL of a file to share in my Dropbox folder from command line. I would avoid to open the web browser every time.

Best Answer

Obtaining the Dropbox Client

You can download the Dropbox client for Linux on Dropbox's Website.

This package will install both the Dropbox daemon (which automatically syncs files to a folder if you configure it to), and the dropbox command line utility.

Pure Command Line

NOTE: Due to changes made to the Public folder by Dropbox, the instructions below no longer work.

In order to obtain a link to a file in Dropbox from the command line, you must now use the sharelink command instead of puburl. For more information, please see jbrock's answer detailing the use of that command.

For more information about the changes to the Public folder, please see this Dropbox help topic.

Assuming you have the Dropbox client installed and in your path, you can get a link to a file in your Public folder using the command:

dropbox puburl <path-to-file>

For example:

dropbox puburl ~/Dropbox/Public/somepic.jpg

However, this will not work for files outside your Public folder, it will simply give the error:

Couldn't get public url: Unknown Error

For more information about the dropbox command line interface, you can read the unofficial wiki.

File Explorer Integration

Just in case you just want to avoid going to the website, instead of needing a pure command-line solution, here's an alternative method.

For URLs to files outside the Public folder, it seems you have to use either the website or use a plugin that adds Dropbox-specific functionality to your file manager. By default, Dropbox supports integration with the Nautilus file manager (aka GNOME Files) for the GNOME desktop environment.

If you have Dropbox integration with your file manager, you can right click on a file and choose the "Share Dropbox Link" item in the "Dropbox" submenu. This will copy a link into your Clipboard.

You can usually tell if you have Dropbox integration with your file manager if, when you browse to your Dropbox folder in the file manager, green check marks appear over synced files.

Depending on your Linux distribution, plugins for different desktop environments may be available in the package repositories. For example, on Linux Mint there are plugins available for Nemo (Cinnamon, package is nemo-dropbox) and Caja (MATE, package is caja-dropbox).

Related Question