How To Use Dropbox From The Linux Command Line With Dropbox Uploader
Dropbox Uploader is a bash script that simplifies the complex Dropbox-cli down to something much easier to understand. With it, uploading and downloading files to Dropbox from the Linux terminal is much easier. Officially, the script lets you use Dropbox from the Linux command line in any Linux distro, BSD, and any other operating system that has a Unix-like terminal structure.
Add Git Package
Before grabbing the script, you’ll need the git package. The git program is required, because without it, grabbing the source code for the program is much more tedious.
Ubuntu
sudo apt install git
Debian
sudo apt-get install git
Arch Linux
sudo pacman -S git
Fedora
sudo dnf install git
OpenSUSE
sudo zypper install git
Other Linuxes
Need the git package, but not sure where to find it? Don’t worry: the git tool is widely used on all of Linux, as a lot of Linux projects go to Github. Chances are, your operating system of choice has the git package. To find it, open your package manager, search for “git” and install it. Alternatively, check the official website for your distribution for more information.
Getting Dropbox Uploader
Now that Git is on the system, and working correctly, we can grab the Dropbox Uploader script. To do this, open up a terminal window. Inside the terminal, run this command.
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
The git clone command will download an entire snapshot of the latest code from the developer, and place it in ~/Dropbox-Uploader in your home folder, on the file system. To go to this directory, use the CD command.
cd ~/Dropbox-Uploader
The next step is to update the permissions of the script. This is important, as the file will not be able to execute as a program without it.
sudo chmod +x dropbox_uploader.sh
Aside from Dropbox Uploader, there are other tools in the git folder. Mainly: DropShell, a Docker file, a readme file, the software license, and a few other things. In this tutorial, we’ll be covering how to use Dropbox Uploader. If you’d like to learn how to use the Docker file, and etc. Go through the readme file, and read the instructions.
Configuring Dropbox Uploader
The first time that Dropbox Uploader runs, a login prompt appears. To run the script, do:
./dropbox_uploader.sh
DO NOT run this script as root, or with sudo privileges. There is no need, as the permissions and etc are correct. In addition, the script makes a configuration folder in the user’s home directory. By running this tool as root, all login info will be stored in the root, which normal users can’t access.
During the initial run of the script, the terminal prompt says: “this is the first time you run this script, please follow the instructions”. Locate the link that the terminal prompt shares with you, and open it in your browser.
The link opens on the Dropbox developer page. Look for the button “create app”, and click it.
Select the option “Dropbox API”. Then, further down, select “Full Dropbox access”. This will ensure the upload tool has complete access to your account. Enter a name in the name section. Be creative, as many names are taken.
After the app is created under your Dropbox account, you’ll be taken to it’s configuration page. Look for “generated access token”, and click the generate button. Copy the code, and paste it into the terminal to log into the Dropbox Uploader.
Using Dropbox Uploader
Logging into Dropbox Uploader quits the script automatically. To use it, you’ll need to launch it again. Do this with:
./dropbox_uploader.sh
List
The Dropbox Uploader can easily list the entire contents of your Dropbox remote folder. This is useful, especially to prepare for downloading files. To use list, do this:
./dropbox_uploader.sh list
List prints out the entire folder structure of your Dropbox. Save the output to a file with:
./dropbox_uploader.sh list >> dropbox-contents.txt
Upload
To upload to Dropbox via the Dropbox Uploader, first move the file into /home/Dropbox-Uploader/. Do this with the file manager. Then, to start the upload, simply run the upload, and specify the folder.
./dropbox_uploader.sh upload testfile.jpg /dropbox/whatever/folder/you/want
Search
Search works a lot like the list feature. The user writes a search query, and the script will filter through a list based on that query. For example, to search for something in Dropbox with an “sh” in it, do:
./dropbox_uploader.sh search sh
The upload tool will then print out a list of all files related to the search term “sh”.
Download
Downloading is fairly straight-forward. First, use either list or search to look through the contents of your Dropbox account. Then, copy the search result (or list result). Be sure to copy the entire directory structure. This means if you’ve got a file inside /Dropbox/testA/testB/misc/file.jpg, it’d be:
./dropbox_uploader.sh download /testA/testB/misc/file.jpg
The reason the Dropbox folder shouldn’t be included, is because the script already knows everything originates from there.
Delete
Deleting can take place directly from the command line. To do it, use “search” or “list” to find the file to delete. Then, delete it with:
./dropbox_uploader.sh delete /whatever/folder/file.jpg
Other Commands
The Dropbox Uploader tool has a very wide feature-set, with many individual features. We’ve gone over the basics, but if you’re looking to do more complex things with the uploader, refer to the help section of the script. This can easily be done by just running the script on it’s own, without any sub commands (list, search etc).
To save the entire help commands to a text file to read for later, do:
./dropbox_uploader.sh >> dropbox-uploader-help.txt
Hi Derek, I’m having a problem with dropbox_uploader.sh
I’ve followed all the steps in your (very clear) instructions, and seem to have passed all the setup. I got to this point:
> Access code: ‘3s9rwuboseceioeaT-1rymRiNAAAAAAAAAdiGAs6U_UHBHjz1TFIOYFbew’. Looks ok? [y/N]: y
The configuration has been saved.
But then when I try to anything with dropbox_uploader.sh I get the message
Error loading data from /home/simon/.dropbox_uploader…
It is recommended to run dropbox_uploader.sh unlink
When I try dropbox_uploader.sh unlink
I get the same message, and can’t get the uploader to accept any commands. Could you advise please?
Thanks very much indeed for your help!
.