How to Download Torrents from the Command Line in Ubuntu

Though Torrenting is usually regarded as a dirty word, there are a lot of positives to using it, especially when talking about Linux. For starters, if you're creating a Linux distribution, it's a great way to outsource your bandwidth. No more hosting download servers. Just give a torrent out to your community, and have them seed the torrent! Low bandwidth bills and fast transfers for everyone!

For the most part, torrenting on Linux is done with GTK clients. Most notably: Transmission-GTK. However, people might be interested to know that it is indeed possible to download torrents directly inside the terminal. How does this all work? Let's find out!

Installation

There are many good CLI-based torrent clients, but few are as good as transmission-cli. It is the easiest to use out of all the choices out there and similar to the most-used torrent client on Linux (Transmission-GTK).

To install transmission-cli, open a terminal window and enter the following command:

sudo apt install transmission-cli

Also read: How to Use the dd Command in Linux

How to add a torrent

Adding a torrent to transmission-cli is pretty straightforward. Start off by finding a torrent file from your preferred torrent distributor. In this tutorial we'll be using the Ubuntu alternative release torrents.

URL

transmission-cli-download-torrent-url

Transmission-cli can download a torrent directly from a URL by doing:

transmission-cli http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads

This method is great if the user is in a pinch and just wants the download to happen as soon as possible.

Magnet Links

This torrent client also has support for magnet links. To download a torrent with a magnet link, try something like this:

transmission-cli magnet:?xt=urn:btih:e249fe4dc957be4b4ce3ecaac280fdf1c71bc5bb&dn=ubuntu-mate-16.10-desktop-amd64.iso -w ~/Downloads

Torrent Files

And lastly, the third way transmission-cli can be downloaded is with a torrent file. Obtain a torrent file by conventional means (through a web browser) or find a link to a torrent file, and download it through the terminal with wget.

For example:

wget http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent

To download with a torrent file, do the following:

transmission-cli ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads

How to enable a peer blocklist

transmission-cli-download-with-blocklist

Since transmission-cli works different than its GTK counterpart, it often doesn't save settings. This means peer blocklists need to be specified each time before use. The -b switch enables a blocklist. To use one while downloading, follow this example:

transmission-cli http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -b http://john.bitsurge.net/public/biglist.p2p.gz

Download with encryption

transmission-cli-download-encryption

Though it's not recommended to download sketchy files from torrents, it happens. To protect yourself while downloading these types of files, it is possible to encrypt the traffic while downloading. Here's how to do it:

transmission-cli http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -er

The -er flag tells transmission-cli to require encryption with all peers that it connects to. This may slow down transfer speeds, so this option might not be for everyone, especially those on slow transfer speeds.

To download with encrypted traffic, but increase transfer speed, try using the prefer encryption switch instead. This will tell peers that the client would prefer encryption, but it won't require it.

transmission-cli http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -ep

Other options

transmission-cli-help-command-page

Transmission-cli is filled to the brim with all sorts of different options. To view these options, enter transmission-cli --help. Doing so will print out different command modifiers and flags that users can add to their transmission-cli commands for a better downloading experience.

Conclusion

As Linux users probably already know, the terminal can do anything. No matter what job, big or small, it can be accomplished in the terminal. Torrenting is no different.

Though it doesn't seem as glamorous to download with a command instead of a fancy GUI, you'd be wrong. Transmission-cli has more features than even most mainstream graphical clients. If you've never tried to torrent on the command line, you're in for a treat.

Derrik Diener

Derrik Diener is a freelance technology blogger.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox